Highlights: Dialog with enterTextarea not updating the controller variable

I have this dialog:

<p:dialog header="Ingrese Comentario" widgetVar="dlg1" appendTo="@(body)" modal="true" position="top" hideEffect="fold" showEffect="fold" closable="true" draggable="true" > <h:form id="d_ingresarComentario"> <h:panelGrid columns="2"> <p:inputTextarea value="#{tareaController.comentarioNuevo.comentario}" rows="7" cols="60" placeholder="Ingrese su comentario aquΓ­" counter="display1" maxlength="200" counterTemplate="{0} Caracteres faltantes." > </p:inputTextarea> <br/> <h:outputText id="display1"/> <f:facet name="footer"> <p:commandButton id ="c_enviar" immediate="true" actionListener="#{tareaController.crearComentario()}" value="Enviar" oncomplete="dlg1.hide()" global="false"> </p:commandButton> </f:facet> </h:panelGrid> </h:form> </p:dialog> 

The button listener works fine, the text area is displayed with a variable value when the dialog is called. But whenever I write in the text area, the variable (comentarioNuevo.comentario), which is a string, is not updated in the controller. It always retains its original meaning. Any idea what I'm doing wrong?

I already tried: typing the value of a variable on the keyboard, and yes, it is always the same. Testing with other components, such as h: inputTextArea or p: inputText and has the same behavior, the variable will not be updated. Yes, my variable has both getter and setter.

My controller code is as follows:

 @ManagedBean @ViewScoped public class TareaController implements Serializable { private Comentario comentario = new Comentario(); public void crearComentario() { comentarioDAO.crearComentario(login.getUsuario(), expediente, comentarioNuevo); nuevoComentario(); } public Comentario getComentarioNuevo() { return comentarioNuevo; } public void setComentarioNuevo(Comentario comentarioNuevo) { this.comentarioNuevo = comentarioNuevo; } } 

This Comentario is a JPA entity that works great on other sides. Additional information: PrimeFaces version 4.0, Mojarra 2.7, JSF 2.2

Thanks for the help!

0
source share
1 answer

You set immediate=true to UICommandComponent, so the "Update Model Values" phase is skipped. Remove the attribute and it should work.

BalusC offers this tip: β€œIf specified only in UICommand, the request phase of the application is applied until the phases of the update model values ​​are skipped for any of the UIInput components. Use this to skip all form processing. For example, the Cancel button or back.

see also

+2
source

All Articles