title: Rendering validation messages RichFaces
body: <p>I have a form where I have a <code>rich:select</code> whether they choose option A or option B an <code>h:inputText</code> is rendered.
  Initially the <code>h:inputText</code> corresponding to option A is rendered and if I leave it blank the <code>requiredMessage</code> appears and everything is OK.
  Now when I select the second option of the <code>rich:select</code> the <code>h:inputText</code> for option B is rendered but if I leave it blank the <code>requiredMessage</code> doesn't appear.</p>
  
  <p>What am I missing?</p>
  
  <p>My xhtml code is as follows:</p>
  
  <pre><code>                &lt;h:panelGrid columns="3"&gt;
                      &lt;h:outputLabel for="tipoPersona"&gt;Tipo de persona&lt;/h:outputLabel&gt;
                      &lt;rich:select id="tipoPersona"
                                   required="true" value="#{userInformationController.tipoPersona}"
                                   requiredMessage="Seleccione el tipo de persona"
                                   defaultLabel="Seleccione una opción"&gt;
                          &lt;f:selectItems value="#{userInformationController.tipoPersonaOpciones}"/&gt;
                          &lt;f:ajax event="blur" render="tipoPersonaMessage"/&gt;
                          &lt;f:ajax event="selectitem"
                                  render="outputLabelCURP inputTextCURP messageCURP outputLabelRFC inputTextRFC messageRFC"
                                  listener="#{userInformationController.doRenderCURP}"/&gt;
                      &lt;/rich:select&gt;
                      &lt;rich:message id="tipoPersonaMessage" ajaxRendered="true"
                                    for="tipoPersona"/&gt;
  
  
                      &lt;a4j:outputPanel id="outputLabelCURP"&gt;
                          &lt;h:outputLabel for="CURP" value="CURP"
                                         rendered="#{userInformationController.curpRendered}"/&gt;
                      &lt;/a4j:outputPanel&gt;                        
                      &lt;a4j:outputPanel id="inputTextCURP"&gt;
                          &lt;h:inputText id="CURP" required="true"
                                       requiredMessage="Introduzca el CURP"
                                       rendered="#{userInformationController.curpRendered}"&gt;
                              &lt;f:ajax event="blur" render="curpMessage"/&gt;
                          &lt;/h:inputText&gt;
                      &lt;/a4j:outputPanel&gt;
                      &lt;a4j:outputPanel id="messageCURP"&gt;
                          &lt;rich:message id="curpMessage" ajaxRendered="true"
                                        for="CURP"
                                        rendered="#{userInformationController.curpRendered}"/&gt;
                      &lt;/a4j:outputPanel&gt;
  
  
                      &lt;a4j:outputPanel id="outputLabelRFC"&gt;
                          &lt;h:outputLabel for="RFC" value="RFC"
                                         rendered="#{not userInformationController.curpRendered}"/&gt;
                      &lt;/a4j:outputPanel&gt;
                      &lt;a4j:outputPanel id="inputTextRFC"&gt;
                          &lt;h:inputText id="RFC" required="true"
                                       requiredMessage="Introduzca el RFC"
                                       rendered="#{not userInformationController.curpRendered}"&gt;
                              &lt;f:ajax event="blur" render="rfcMessage"/&gt;
                          &lt;/h:inputText&gt;
                      &lt;/a4j:outputPanel&gt;
                      &lt;a4j:outputPanel id="messageRFC"&gt;
                          &lt;rich:message id="rfcMessage" ajaxRendered="true"
                                        for="RFC"
                                        rendered="#{not userInformationController.curpRendered}"/&gt;
                      &lt;/a4j:outputPanel&gt;
                  &lt;/h:panelGrid&gt;
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I have made some changes on the UI and now I have this</p>
  
  <pre><code>            &lt;fieldset&gt;
                  &lt;legend&gt;Datos SURI&lt;/legend&gt;
                  &lt;h:panelGrid columns="3"&gt;
                      &lt;h:outputLabel for="tipoPersona"&gt;Tipo de persona&lt;/h:outputLabel&gt;
                      &lt;rich:select id="tipoPersona"
                                   required="true" value="#{userInformationController.tipoPersona}"
                                   requiredMessage="Seleccione el tipo de persona"
                                   defaultLabel="Seleccione una opción"&gt;
                          &lt;f:selectItems value="#{userInformationController.tipoPersonaOpciones}"/&gt;
                          &lt;f:ajax event="blur" render="tipoPersonaMessage"/&gt;
                          &lt;f:ajax event="selectitem"
                                  render="outputLabelCURP inputTextCURP messageCURP 
                                          outputLabelRFC inputTextRFC messageRFC
                                          datosPersonaFisica datosPersonaMoral"
                                  listener="#{userInformationController.doRenderTipoPersona}"/&gt;
                      &lt;/rich:select&gt;
                      &lt;rich:message id="tipoPersonaMessage" ajaxRendered="true"
                                    for="tipoPersona"/&gt;
  
  
                      &lt;a4j:outputPanel id="outputLabelCURP"&gt;
                          &lt;h:outputLabel for="CURP" value="CURP"
                                         rendered="#{userInformationController.personaFisicaRendered}"/&gt;
                      &lt;/a4j:outputPanel&gt;                        
                      &lt;a4j:outputPanel id="inputTextCURP"&gt;
                          &lt;h:inputText id="CURP" required="true"
                                       requiredMessage="Introduzca el CURP"
                                       value="#{userInformationController.curp}"
                                       rendered="#{userInformationController.personaFisicaRendered}"&gt;
                              &lt;f:ajax event="blur" render="curpMessage identificadorSURI"
                                      listener="#{userInformationController.doSearchIdSURI}"/&gt;
                          &lt;/h:inputText&gt;
                      &lt;/a4j:outputPanel&gt;
                      &lt;a4j:outputPanel id="messageCURP"&gt;
                          &lt;rich:message id="curpMessage" ajaxRendered="true" for="CURP"
                                        rendered="#{userInformationController.personaFisicaRendered}"/&gt;
                      &lt;/a4j:outputPanel&gt;
  
  
                      &lt;a4j:outputPanel id="outputLabelRFC"&gt;
                          &lt;h:outputLabel for="RFC" value="RFC"
                                         rendered="#{userInformationController.personaMoralRendered}"/&gt;
                      &lt;/a4j:outputPanel&gt;
                      &lt;a4j:outputPanel id="inputTextRFC"&gt;
                          &lt;h:inputText id="RFC" required="true"
                                       requiredMessage="Introduzca el RFC"
                                       value="#{userInformationController.rfc}"
                                       rendered="#{userInformationController.personaMoralRendered}"&gt;
                              &lt;f:ajax event="blur" render="rfcMessage identificadorSURI"
                                      listener="#{userInformationController.doSearchIdSURI}"/&gt;
                          &lt;/h:inputText&gt;
                      &lt;/a4j:outputPanel&gt;
                      &lt;a4j:outputPanel id="messageRFC"&gt;
                          &lt;rich:message id="rfcMessage" ajaxRendered="true" for="RFC"
                                        rendered="#{userInformationController.personaMoralRendered}"/&gt;
                      &lt;/a4j:outputPanel&gt;
  
                      &lt;h:outputLabel for="identificadorSURI"&gt;Identificador SURI&lt;/h:outputLabel&gt;
                      &lt;h:inputText id="identificadorSURI" disabled="true"
                                   value="#{userInformationController.identificadorSuri}"/&gt;
  
                  &lt;/h:panelGrid&gt;
              &lt;/fieldset&gt;
  </code></pre>
  
  <p>However, I found that putting my Bean in <strong>RequestScope</strong> isn't firing the listener on both of the <code>h:inputText</code> (id='CURP' and id='RFC'), whereas if I put the bean in <strong>ViewScope</strong> the listener is getting fired and processed correctly.</p>
  
  <p>What I need is to actually have the Bean in RequestScope because I need to create a whole new form whether the user changes the value of the <code>rich:select</code>. If I keep the scope in ViewScope all the data is kept within the Bean and I will then have to erase the fields when the user changes the value of the select.</p>
  
  <p>Can someone explain to me why is this happening? I could'n figure out what's the trick !</p>
  
  <p>Cheers</p>