1 2 Previous Next 19 Replies Latest reply on Mar 1, 2011 4:28 AM by Ilya Shaikovsky

    h:message not reRendered when using f:ajax...

    Julien Martin Expert

      Hello,

      I have an issue with RF4 M6 and f:ajax. I am trying to migrate a RF3 application to RF4. Here is my facelet code:

      {code}

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"

                      xmlns:ui="http://java.sun.com/jsf/facelets"

                      xmlns:h="http://java.sun.com/jsf/html"

                      xmlns:f="http://java.sun.com/jsf/core"

                      xmlns:a4j="http://richfaces.org/a4j"

                      xmlns:rich="http://richfaces.org/rich">

          <a4j:region>

              <h:panelGrid id="formulaireContactP" columns="3" columnClasses="libellesColonne,champsColonne,validiteColonne">

                  <h:outputText value="#{msg['message.from.email']}" />

                  <a4j:outputPanel id="fromEmail">

                      <h:inputText id="email"

                                   value="#{contactView.message.email}"

                                   required="true"

                                   requiredMessage="#{msg['message.valeurRequise.email']}"

                                   validatorMessage="#{msg['message.erreur.email']}"

                                   binding="#{contactView.bb.emailI}"

                                   maxlength="50"

                                   size="20"

                                   styleClass="emailI">

                          <f:ajax listener="#{contactView.valider}" render="fromEmail emailMP"/>

                          <f:validator validatorId="adresseEmailValidator" />

                      </h:inputText>

                  </a4j:outputPanel>

                  <a4j:outputPanel id="emailMP" ajaxRendered="true">

                      <h:message for="email"  infoClass="champValide" styleClass="champInvalide"/>

                  </a4j:outputPanel>

       

       

                  <h:outputText value="#{msg['message.from.nom']}" />

                  <a4j:outputPanel id="nom">

                      <h:inputText id="nomI"

                                   value="#{contactView.message.nom}"

                                   required="true"

                                   requiredMessage="#{msg['message.valeurRequise.nom']}"

                                   binding="#{contactView.bb.nomI}"

                                   maxlength="50"

                                   size="20"

                                   styleClass="nomI">

                           <f:ajax listener="#{contactView.valider}" render="nom nomMP"/>

                          <f:validateLength minimum="3" />

                      </h:inputText>

                  </a4j:outputPanel>

                  <a4j:outputPanel id="nomMP" ajaxRendered="false">

                      <h:message for="nomI" infoClass="champValide" styleClass="champInvalide"/>

                  </a4j:outputPanel>

       

       

                  <h:outputText value="#{msg['message.sujet']}" rendered="false"/>

                  <a4j:outputPanel id="sujet" rendered="false">

                      <h:inputText id="sujetI" value="#{contactView.message.sujetMessage}" required="true"

                                   requiredMessage="#{msg['message.valeurRequise.sujet']}" validatorMessage="#{msg['message.erreur.sujet']}" binding="#{contactView.bb.sujetI}" maxlength="50" size="20">

                          <f:validateLength minimum="2" />

                      </h:inputText>

                  </a4j:outputPanel>

                  <a4j:outputPanel id="sujetMP" ajaxRendered="true" rendered="false">

                      <h:message for="sujetI" infoClass="champValide" styleClass="champInvalide" rendered="true"/>

                  </a4j:outputPanel>

       

       

                  <h:outputText value="#{msg['message.corps']}" />

                  <a4j:outputPanel id="corps">

                      <h:inputTextarea id="corpsI"

                                       value="#{contactView.message.corpsMessage}"

                                       cols="25"

                                       rows="5"

                                       required="true"

                                       requiredMessage="#{msg['message.valeurRequise.corps']}"

                                       validatorMessage="#{msg['message.erreur.corps']}"

                                       binding="#{contactView.bb.corpsI}">

                          <f:validateLength minimum="15" maximum="1000" />

                      </h:inputTextarea>

                  </a4j:outputPanel>

                  <a4j:outputPanel id="corpsMP" ajaxRendered="true" >

                      <h:message for="corpsI" infoClass="champValide" styleClass="champInvalide" style="vertical-align: top"/>

                  </a4j:outputPanel>

       

       

                  <a4j:outputPanel rendered="false">

                      <h:outputText value="#{msg['message.texte.recopier']}" />

                  </a4j:outputPanel>

                  <a4j:outputPanel id="captchaImage" ajaxRendered="true" style="min-height:50px;min-width:150px;" rendered="false">

                      <h:graphicImage value="/CaptchaServlet?param=#{contactView.now}&amp;locale=#{view.locale.language}" height="50" width="150" alt="#{msg['message.texte.recopier']}" title="#{msg['message.texte.recopier']}"/>

                  </a4j:outputPanel>

                  <a4j:outputPanel rendered="false"/>

       

       

                  <a4j:outputPanel rendered="false">

                      <h:outputText value="#{msg['message.recopier.ici']}" />

                  </a4j:outputPanel>

                  <a4j:outputPanel id="secureText" rendered="false">

                      <h:inputText id="secureTextI" value="#{contactView.secureText}" validatorMessage="#{msg['message.captcha.requis']}" requiredMessage="#{msg['message.captcha.requis']}" maxlength="50" size="20" required="true" binding="#{contactView.bb.secureTextI}">

                          <f:validator validatorId="captchaValidator" />

                      </h:inputText>

                  </a4j:outputPanel>

                  <a4j:outputPanel id="secureTextMP" rendered="false">

                      <h:message for="secureTextI" styleClass="champInvalide" />

                  </a4j:outputPanel>

                  <a4j:outputPanel layout="block" styleClass="formulaireContactLoader">

                      <ui:include src="status-bar.xhtml"/>

                  </a4j:outputPanel>

                  <a4j:outputPanel layout="block" styleClass="formulaireContactFooter">

                      <h:commandButton id="envoyerMessage" action="#{contactView.envoyer}" type="submit" value="#{msg['message.envoyer']}" styleClass="form-button">

                          <f:ajax execute="@form" listener="#{contactView.valider}" render="formulaireContactP"/>

                      </h:commandButton>

                  </a4j:outputPanel>

              </h:panelGrid>

              <a4j:outputPanel>

                  <h:message for="envoyerMessage" infoClass="champValide"/>

              </a4j:outputPanel>

          </a4j:region>

      </ui:composition>

      {code}

       

      And my validating method:

      {code}

      public void valider(ActionEvent evt) {

              log.debug("valider");

              UIInput comp = (UIInput) evt.getComponent().getParent();

              FacesContext fc = FacesContext.getCurrentInstance();

              ResourceBundle rb = ResourceBundle.getBundle("resources", fc.getViewRoot().getLocale());

              try {

                  comp.validate(fc);

                  FacesMessage fm = new FacesMessage();

                  fm.setSeverity(FacesMessage.SEVERITY_INFO);

                  fc.addMessage(comp.getClientId(fc), fm);

              } catch (ValidatorException ve) {

                  FacesMessage fm = new FacesMessage();

                  fm.setSeverity(FacesMessage.SEVERITY_ERROR);

                  fm.setSummary(rb.getString("message.erreur.validation"));

                  fm.setDetail(rb.getString("message.erreur.validation"));

                  throw new ValidatorException(fm);

              }

          }

       

      {code}

       

      When I submit the form, nothing happens: if the data in the form in not valid nothing happens. If it is nothing happens either.

       

      Can anyone please help?

       

      Thanks in advance,

       

      Julien.

        1 2 Previous Next