Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7775125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:33:03+00:00 2026-06-01T17:33:03+00:00

I have a form where I have a rich:select whether they choose option A

  • 0

I have a form where I have a rich:select whether they choose option A or option B an h:inputText is rendered.
Initially the h:inputText corresponding to option A is rendered and if I leave it blank the requiredMessage appears and everything is OK.
Now when I select the second option of the rich:select the h:inputText for option B is rendered but if I leave it blank the requiredMessage doesn’t appear.

What am I missing?

My xhtml code is as follows:

                <h:panelGrid columns="3">
                    <h:outputLabel for="tipoPersona">Tipo de persona</h:outputLabel>
                    <rich:select id="tipoPersona"
                                 required="true" value="#{userInformationController.tipoPersona}"
                                 requiredMessage="Seleccione el tipo de persona"
                                 defaultLabel="Seleccione una opción">
                        <f:selectItems value="#{userInformationController.tipoPersonaOpciones}"/>
                        <f:ajax event="blur" render="tipoPersonaMessage"/>
                        <f:ajax event="selectitem"
                                render="outputLabelCURP inputTextCURP messageCURP outputLabelRFC inputTextRFC messageRFC"
                                listener="#{userInformationController.doRenderCURP}"/>
                    </rich:select>
                    <rich:message id="tipoPersonaMessage" ajaxRendered="true"
                                  for="tipoPersona"/>


                    <a4j:outputPanel id="outputLabelCURP">
                        <h:outputLabel for="CURP" value="CURP"
                                       rendered="#{userInformationController.curpRendered}"/>
                    </a4j:outputPanel>                        
                    <a4j:outputPanel id="inputTextCURP">
                        <h:inputText id="CURP" required="true"
                                     requiredMessage="Introduzca el CURP"
                                     rendered="#{userInformationController.curpRendered}">
                            <f:ajax event="blur" render="curpMessage"/>
                        </h:inputText>
                    </a4j:outputPanel>
                    <a4j:outputPanel id="messageCURP">
                        <rich:message id="curpMessage" ajaxRendered="true"
                                      for="CURP"
                                      rendered="#{userInformationController.curpRendered}"/>
                    </a4j:outputPanel>


                    <a4j:outputPanel id="outputLabelRFC">
                        <h:outputLabel for="RFC" value="RFC"
                                       rendered="#{not userInformationController.curpRendered}"/>
                    </a4j:outputPanel>
                    <a4j:outputPanel id="inputTextRFC">
                        <h:inputText id="RFC" required="true"
                                     requiredMessage="Introduzca el RFC"
                                     rendered="#{not userInformationController.curpRendered}">
                            <f:ajax event="blur" render="rfcMessage"/>
                        </h:inputText>
                    </a4j:outputPanel>
                    <a4j:outputPanel id="messageRFC">
                        <rich:message id="rfcMessage" ajaxRendered="true"
                                      for="RFC"
                                      rendered="#{not userInformationController.curpRendered}"/>
                    </a4j:outputPanel>
                </h:panelGrid>

UPDATE

I have made some changes on the UI and now I have this

            <fieldset>
                <legend>Datos SURI</legend>
                <h:panelGrid columns="3">
                    <h:outputLabel for="tipoPersona">Tipo de persona</h:outputLabel>
                    <rich:select id="tipoPersona"
                                 required="true" value="#{userInformationController.tipoPersona}"
                                 requiredMessage="Seleccione el tipo de persona"
                                 defaultLabel="Seleccione una opción">
                        <f:selectItems value="#{userInformationController.tipoPersonaOpciones}"/>
                        <f:ajax event="blur" render="tipoPersonaMessage"/>
                        <f:ajax event="selectitem"
                                render="outputLabelCURP inputTextCURP messageCURP 
                                        outputLabelRFC inputTextRFC messageRFC
                                        datosPersonaFisica datosPersonaMoral"
                                listener="#{userInformationController.doRenderTipoPersona}"/>
                    </rich:select>
                    <rich:message id="tipoPersonaMessage" ajaxRendered="true"
                                  for="tipoPersona"/>


                    <a4j:outputPanel id="outputLabelCURP">
                        <h:outputLabel for="CURP" value="CURP"
                                       rendered="#{userInformationController.personaFisicaRendered}"/>
                    </a4j:outputPanel>                        
                    <a4j:outputPanel id="inputTextCURP">
                        <h:inputText id="CURP" required="true"
                                     requiredMessage="Introduzca el CURP"
                                     value="#{userInformationController.curp}"
                                     rendered="#{userInformationController.personaFisicaRendered}">
                            <f:ajax event="blur" render="curpMessage identificadorSURI"
                                    listener="#{userInformationController.doSearchIdSURI}"/>
                        </h:inputText>
                    </a4j:outputPanel>
                    <a4j:outputPanel id="messageCURP">
                        <rich:message id="curpMessage" ajaxRendered="true" for="CURP"
                                      rendered="#{userInformationController.personaFisicaRendered}"/>
                    </a4j:outputPanel>


                    <a4j:outputPanel id="outputLabelRFC">
                        <h:outputLabel for="RFC" value="RFC"
                                       rendered="#{userInformationController.personaMoralRendered}"/>
                    </a4j:outputPanel>
                    <a4j:outputPanel id="inputTextRFC">
                        <h:inputText id="RFC" required="true"
                                     requiredMessage="Introduzca el RFC"
                                     value="#{userInformationController.rfc}"
                                     rendered="#{userInformationController.personaMoralRendered}">
                            <f:ajax event="blur" render="rfcMessage identificadorSURI"
                                    listener="#{userInformationController.doSearchIdSURI}"/>
                        </h:inputText>
                    </a4j:outputPanel>
                    <a4j:outputPanel id="messageRFC">
                        <rich:message id="rfcMessage" ajaxRendered="true" for="RFC"
                                      rendered="#{userInformationController.personaMoralRendered}"/>
                    </a4j:outputPanel>

                    <h:outputLabel for="identificadorSURI">Identificador SURI</h:outputLabel>
                    <h:inputText id="identificadorSURI" disabled="true"
                                 value="#{userInformationController.identificadorSuri}"/>

                </h:panelGrid>
            </fieldset>

However, I found that putting my Bean in RequestScope isn’t firing the listener on both of the h:inputText (id=’CURP’ and id=’RFC’), whereas if I put the bean in ViewScope the listener is getting fired and processed correctly.

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 rich:select. 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.

Can someone explain to me why is this happening? I could’n figure out what’s the trick !

Cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:33:04+00:00Added an answer on June 1, 2026 at 5:33 pm

    A request scoped bean is recreated on every single request, also on every single ajax request. So when you change a property by ajax to a new value other than default (e.g. the one responsible for rendered attribute), then this change won’t be retained in the subsequent requests. So the rendered attribute effectively evaluates to false and the component and all its children won’t be processed anymore during the submit.

    The view scope is intended to solve exactly this problem. The bean will live as long as you’re interacting with the same view by ajax requests, until you navigate away to a different view or recreate the view. As to the functional requirement of recreating the form on change of <rich:select>, just do that inside the doRenderTipoPersona() method.

    If you really need to stick to the request scope, then you’d need to retain the bean’s properties manually based on the request parameter map inside the (post)constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a aspx form where we have used freetextbox as my rich text
I have created a Windows form using Visual C# - this contains a rich
I'm working on a windows form application and I want to have a rich
I have a rich panel that contains a form. This form is posted with
I have a an HTML form which contains the YAHOO rich text editor on
Iam using tinymce_hammer as a rich text editor. But now i have a form
I have a form with a rich text box control. Is there a way
I have form with 1 button. when you click on the button 3 others
I have form with few buttons and I want to know what button is
I have form where user submits field. Field can have letters, numbers, and punctuation.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.