The button invoke the action method only when in the JSF view I delete JSTL code, I know that it is abour lifecycle but I dont understand the cause/problem. I like to comprime because it ocurrs this behavior.
view code work fine
<f:metadata>
<f:viewParam name="idAsociacion" value="#{msgUsuario.asociacion}" converter="#
{asociacionConverter}"
converterMessage="#msg['aplicacion.asociacion.error.converter']}" required="true"
requiredMessage="#{msg['aplicacion.asociacion.error.required']}" />
<f:viewParam name="idMsg" value="#{msgUsuario.mensajeRespondido}" converter="#
{mensajeConverter}" converterMessage="#{msg['aplicacion.mensaje.error.converter']}"
required="true" requiredMessage="#{msg['aplicacion.mensaje.error.required']}" />
</f:metadata>
<ui:decorate template="/WEB-INF/templates/mainUsuario-template.xhtml">
<ui:define name="title">
<h:outputFormat value="#{msg['usuario.escribirMsj.title']}">
<f:param value="#{msgUsuario.asociacion.nombre}" />
</h:outputFormat>
</ui:define>
<ui:param name="descripcionView" value="#{msg['usuario.escribirMsj.descripcion']}" />
<ui:define name="content">
<h:panelGroup layout="block"
id="escribirMensajeContainer"styleClass="escribirMensajeContainer">
<h:form>
<p:panelGrid>
<p:row>
<p:column>
<h:outputLabel for="texto" value="#{msg['usuario.escribirMsj.mensaje']}"
styleClass="labelInput" />
</p:column>
</p:row>
<p:row>
<p:column>
<p:inputTextarea autoResize="true" cols="80" rows="15" id="texto"
maxlength="500" value="#{msgUsuario.texto}">
</p:inputTextarea>
</p:column>
</p:row>
<p:row>
<p:column>
<h:message for="texto" id="messageMensajeError" styleClass="messageError" />
</p:column>
</p:row>
<p:row>
<p:column>
<p:commandButton action="#{msgUsuario.enviar}"
alt="#{msg['usuario.escribirMsj.alt.enviar']}" tabindex="2" title="#
{fn:replace(msg['usuario.escribirMsj.title.enviar'],0,msgUsuario.asociacion.nombre)}"
value="#{msg['usuario.escribirMsj.enviar']}" />
</p:column>
</p:row>
</p:panelGrid>
</h:form>
</h:panelGroup>
</ui:define>
</ui:decorate>
</html>
But if I add JSTL how I show below. The view render fine because the message is not responsed but the button never invoke the action method and the view reload.
<c:choose>
<c:when test="#{msgUsuario.mensajeRespondido.respondido==false}">
<h:form>
<p:panelGrid>
<p:row>
<p:column>
<h:outputLabel for="texto" value="#{msg['usuario.escribirMsj.mensaje']}"
styleClass="labelInput" />
</p:column>
</p:row>
<p:row>
<p:column>
<p:inputTextarea autoResize="true" cols="80" rows="15" id="texto"
maxlength="500" value="#{msgUsuario.texto}">
</p:inputTextarea>
</p:column>
</p:row>
<p:row>
<p:column>
<h:message for="texto" id="messageMensajeError" styleClass="messageError" />
</p:column>
</p:row>
<p:row>
<p:column>
<p:commandButton action="#{msgUsuario.enviar}"
alt="#{msg['usuario.escribirMsj.alt.enviar']}" tabindex="2" title="#
{fn:replace(msg['usuario.escribirMsj.title.enviar'],0,msgUsuario.asociacion.nombre)}"
value="#{msg['usuario.escribirMsj.enviar']}" />
</p:column>
</p:row>
</p:panelGrid>
</h:form>
</c:when>
<c:otherwise>
<h:outputText value="MESSAGE RESPONSED" />
</c:otherwise>
</c:choose>
Note: Converts work fine in two case.
ManagedBean code
@ManagedBean(name="msgUsuario")
@ViewScoped
public class EscribirMensajeUsuarioView implements Serializable {
private static final long serialVersionUID = 1L;
private static final Logger logger=Logger.getLogger(EscribirMensajeUsuarioView.class);
private Asociacion asociacion;
private Mensaje mensajeRespondido;
private Usuario usuario;
private String texto;
private boolean usuarioBloqueado;
@ManagedProperty(value="#{mensajeBO}")
private MensajeBO mensajeBo;
@ManagedProperty(value="#{usuarioBO}")
private UsuarioBO usuarioBo;
/* Never invoked with JSTL code in the view */
public String enviar(){
logger.info("EscribirMensajesUsuarioView.enviar");
TipoMensaje tipoMensaje=null;
Mensaje mensaje=this.mensajeRespondido;
.................
.................
.................
}
/* Getters and Setters */
}
I read this Balusc's comment
"JSF and JSTL doesn't run in sync as you'd expect from the coding. JSTL runs during build time of the view (when the JSF component tree is to be populated) and JSF runs during render time of the view component tree (when HTML output is to be generated). You can visualize it as follows: JSTL runs first from top to bottom and then hands over the result to JSF which in turn runs from top to bottom again."
I understand this in dinamyc datatable for example, but not in this case. Because JSTL render fine the view being that mensajeRepetido exit in the JSF tree, but button doesnt invoke the method.However the view reload and mensajeRepetido exits again by the converter.
Kind regards.