6 Replies Latest reply on Dec 19, 2008 3:00 AM by nschweig

    a4j:support selectOneRadio rerendering not working

    nschweig

      Hi,

      I want to use a <h:selectOneRadio> with a4j:support. If the value changes in the selectOneRadio, the <h:listbox id="groups...> should be rerendered.

      <h:selectOneRadio layout="pagedirection" value="#{appointmentBean.appointmentType}">
       <f:selectItem itemValue="#{appointmentBean.appointmentType_general}" itemLabel="fuer alle verfuegbar" />
       <f:selectItem itemValue="#{appointmentBean.appointmentType_group}" itemLabel="fuer Gruppe verfuegbar"/>
       <a4j:support event="onchange" reRender="groups" />
       </h:selectOneRadio>
      
       <h:selectOneListbox value="#{appointmentBean.relatedGroupId}" id="groups" rendered="#{appointmentBean.appointmentType_group}">
       <f:selectItems value="#{groupBean.allGroupsAsItems}"/>
       </h:selectOneListbox>


      If the value of the radiobutton is
      appointmentType_general
      the listbox should not be rendered because there is a rendering condition:
      <h:selectOneListbox value="#{appointmentBean.relatedGroupId}" id="groups" rendered="#{appointmentBean.appointmentType_group}">


      My first problem is that if I invoke the page at the first time, the selectOneRadio-Boxes are both unselected.
      But in my bean I initialized the values:
      ...
      ...appointmentType_general=true;
      ...appointmentType_group=false;
      ...


      The second problem is that if I change the value in the selectOneRadio the ajax request is fired. I can see in the debugger that in my bean the isAppointmentType_group() method is invoked and the values are set right. But on the page the listbox is not rendered.

      Here is my beancode:
      ...
       public void setAppointmentType(String appointmentType) {
       if(appointmentType.equals("appointmentType_general")){
       this.appointmentType_general=true;
       this.appointmentType_group=false;
       }
       else{
       this.appointmentType_general=false;
       this.appointmentType_group=true;
       }
       }
      public boolean isAppointmentType_general() {
       return appointmentType_general;
       }
      
       public void setAppointmentType_general(boolean appointmentType_general) {
       this.appointmentType_general = appointmentType_general;
       }
      
       public boolean isAppointmentType_group() {
       return appointmentType_group;
       }
      
       public void setAppointmentType_group(boolean appointmentType_group) {
       this.appointmentType_group = appointmentType_group;
       }
      ...


      Any ideas?
      Thanks, Nicki


        • 1. Re: a4j:support selectOneRadio rerendering not working
          nbelaevski
          • 2. Re: a4j:support selectOneRadio rerendering not working
            nschweig

            Hi and thanks for your answer.

            Now the default value works for the radiobuttons; I initialized the value in the bean.

            ...
            public String showNewAppointment(){
             setAppointmentType("general");
             return "new_appointment";
             }



            I now use the a4j:outputPanel and the behaviour is very strange.
             <h:selectOneRadio layout="pagedirection" value="#{appointmentBean.appointmentType}">
             <f:selectItem itemValue="general" itemLabel="fuer alle verfuegbar" />
             <f:selectItem itemValue="group" itemLabel="fuer Gruppe verfuegbar"/>
             <a4j:support event="onchange" reRender="groups" />
             </h:selectOneRadio>
            
            
             <a4j:outputPanel layout="none">
             <h:selectOneListbox id="groups" value="#{appointmentBean.relatedGroupId}" rendered="#{appointmentBean.appointmentType_group}">
             <f:selectItems value="#{groupBean.allGroupsAsItems}"/>
             </h:selectOneListbox>
             </a4j:outputPanel>


            Beancode(again because I changed sth.):

            public void setAppointmentType(String appointmentType) {
             this.appointmentType = appointmentType;
             if(appointmentType.equals("group")){
             appointmentType_group = true;
             appointmentType_general = false;
             }
             if(appointmentType.equals("general")){
             appointmentType_group = false;
             appointmentType_general = true;
             }
             }
            
             public boolean isAppointmentType_group() {
             return appointmentType_group;
             }


            The default value was "general". When I now click on "groups" the panel is reRendered how I wanted. But when I then click an "general" all the methods are invoked again and the values are set right in the bean but the panel is not reREndered (without the listbox).

            What is the reason for that?

            Thanks again.
            Nicki

            • 3. Re: a4j:support selectOneRadio rerendering not working
              ilya_shaikovsky

              add ajaxSingle="true" to your support.

              • 4. Re: a4j:support selectOneRadio rerendering not working
                nschweig

                Hi,

                thanks but that is not the solution

                <a4j:support event="onchange" reRender="groups" ajaxSingle="true" />


                does not work too.

                Any more ideas?

                • 5. Re: a4j:support selectOneRadio rerendering not working
                  ilya_shaikovsky

                  will there be some difference if you move the groups id to outputPanel and use layout block instead of none? There where some issues with none layout in the past..

                  • 6. Re: a4j:support selectOneRadio rerendering not working
                    nschweig

                    Hi, thanks, thats it.
                    I tried it with the id in the panel before but without the ajaxSingle in the support-tag...

                    Here my code if someone is interested:

                    <h:selectOneRadio layout="pagedirection" value="#{appointmentBean.appointmentType}">
                     <f:selectItem itemValue="general" itemLabel="fuer alle verfuegbar" />
                     <f:selectItem itemValue="group" itemLabel="fuer Gruppe verfuegbar"/>
                     <a4j:support event="onchange" reRender="groups" ajaxSingle="true" />
                     </h:selectOneRadio>
                    
                    
                     <a4j:outputPanel layout="block" id="groups">
                     <h:selectOneListbox value="#{appointmentBean.relatedGroupId}" rendered="#{appointmentBean.appointmentType_group}">
                     <f:selectItems value="#{groupBean.allGroupsAsItems}"/>
                     </h:selectOneListbox>
                     </a4j:outputPanel>