4 Replies Latest reply on Oct 12, 2010 6:22 AM by ilya_shaikovsky

    How to get radio button value in onclick and open model panel and close modelpanel?

    sivaprasad9394

      Hi,

       

      My problem is ,I have to get the radio button value in onclick event and there i have to hide my modelpanel and open new modelpanel.My radio button is in Modelpanel.

      How to do this in javascript(client-side) and Backing bean?

       

       

      <h:selectOneRadio  id="broadCastOption" onclick="ChangeModelPanel();">

      <f:selectItem id="yesoption" itemValue="true" itemLabel="Yes"/>

      <f:selectItem id="Nooption" itemValue="false" itemLabel="No"/>

      </h:selectOneRadio>

       

       

       

      <h:selectOneRadio  id="broadCastOption" onclick="ChangeModelPanel();">
      <f:selectItem id="yesoption" itemValue="true" itemLabel="Yes"/>
      <f:selectItem id="Nooption" itemValue="false" itemLabel="No"/>
      <a4j:support event="onclick" reRender="info_changemobile_editmodal" ajaxSingle="true" bypassUpdates="true" />
      </h:selectOneRadio>
        • 1. Re: How to get radio button value in onclick?
          ilya_shaikovsky

          if you need to pass it to server side - define valuchangelistener  and add a4j:support to onclick. Then you will be able to reRender content you need and open another panel in oncomplete.

          • 2. Re: How to get radio button value in onclick and open model panel and close modelpanel?
            sivaprasad9394

            Hi ilya,

            Thanks for your reply.

               For me both radio button YES and NO model panel is opening,below is my code,Only for yes i have to show new model panel.old one should be hided.

             

             

             

            <a4j:outputPanel ajaxRendered="true">

                        <a4j:region renderRegionOnly="true">

            <h:selectOneRadio  id="broadCastOption"  valueChangeListener="#{generalInformationBean.selectRadioValue}">

            <a4j:support event="onclick" ajaxSingle="true"

               reRender="broadCastOption,info_changemobile_editmodal,info_msisdn_no_searchmodal"

               oncomplete="if (#{generalInformationBean.rdoButtonFlag == 'true'})Richfaces.hideModalPanel('info_changemobile_editmodal');Richfaces.showModalPanel('info_msisdn_no_searchmodal');" />

            <f:selectItem id="yesoption" itemValue="true" itemLabel="Yes"/>

            <f:selectItem id="Nooption" itemValue="false" itemLabel="No"/>

            </h:selectOneRadio>

            </a4j:region>

            </a4j:outputPanel>

             

             

             

             

            public void selectRadioValue(ValueChangeEvent event)

            {

            HtmlSelectOneRadio radio=(HtmlSelectOneRadio) event.getComponent();

            System.out.println(radio.getValue());

            if(radio.getValue().toString().equalsIgnoreCase("true")){

            System.out.println("TRUE:"+radio.getValue().toString());

            setRdoButtonFlag(true);

            }

            else

            {

            System.out.println("FALSE:"+radio.getValue().toString());

            setRdoButtonFlag(false);

            }

            }

             

             

            How open only for the YES radio button.??

             

            <a4j:outputPanel ajaxRendered="true">
                             <a4j:region renderRegionOnly="true">
            <h:selectOneRadio  id="broadCastOption"  valueChangeListener="#{generalInformationBean.selectRadioValue}">
            <a4j:support event="onclick" ajaxSingle="true"
              reRender="broadCastOption,info_changemobile_editmodal,info_msisdn_no_searchmodal"
              oncomplete="if (#{generalInformationBean.rdoButtonFlag == 'true'})Richfaces.hideModalPanel('info_changemobile_editmodal');Richfaces.showModalPanel('info_msisdn_no_searchmodal');" />
            <f:selectItem id="yesoption" itemValue="true" itemLabel="Yes"/>
            <f:selectItem id="Nooption" itemValue="false" itemLabel="No"/>                  
            </h:selectOneRadio>
            </a4j:region>
            </a4j:outputPanel>
            • 3. Re: How to get radio button value in onclick and open model panel and close modelpanel?
              sivaprasad9394

              HI all,

               

              I have fixed the issue with the following code,

               

              <h:selectOneRadio  id="broadCastOption"  valueChangeListener="#{generalInformationBean.selectRadioValue}">  
              <a4j:support event="onclick" ajaxSingle="true"
                reRender="broadCastOption,info_changemobile_editmodal,info_msisdn_no_searchmodal"
                data="#{generalInformationBean.rdoButtonFlag}"
                oncomplete="if(data==true)
                {
                    #{rich:component('info_changemobile_editmodal')}.hide();
                  #{rich:component('info_msisdn_no_searchmodal')}.show();
                }
                else
                {
                        return false;
                }"/>
               
              <f:selectItem id="yesoption" itemValue="true" itemLabel="Yes"/>
              <f:selectItem id="Nooption" itemValue="false" itemLabel="No"/>                    
              </h:selectOneRadio>

              <h:selectOneRadio  id="broadCastOption"  valueChangeListener="#{generalInformationBean.selectRadioValue}">  

              <a4j:support event="onclick" ajaxSingle="true"

                 reRender="broadCastOption,info_changemobile_editmodal,info_msisdn_no_searchmodal"

                 data="#{generalInformationBean.rdoButtonFlag}"

                 oncomplete="if(data==true)

                 {

                #{rich:component('info_changemobile_editmodal')}.hide();

                   #{rich:component('info_msisdn_no_searchmodal')}.show();

                 }

                 else

                 {

                return false;

                 }"/>

                

              <f:selectItem id="yesoption" itemValue="true" itemLabel="Yes"/>

              <f:selectItem id="Nooption" itemValue="false" itemLabel="No"/>

              </h:selectOneRadio>

              • 4. Re: How to get radio button value in onclick and open model panel and close modelpanel?
                ilya_shaikovsky

                yup I've also used that code when it was requested in the past.