3 Replies Latest reply: Nov 8, 2012 4:21 AM by Cvele_new_account RSS

    Enable Button on selectOneChoice value change

    $AM$
      Hi Friends,

      I am using JDeveloper 11.1.1.5.0.

      I dragged and dropped one selectOneChoice from the data control and one button from the component palette.

      Now, I just want to enable the button on the selectOneChoice value change. If the value is not changed then the button will be disabled.

      Please help me.

      Thanks,

      $@M$
        • 1. Re: Enable Button on selectOneChoice value change
          Sudipto Desmukh
          Make the visible property of the button to false in the property inspector.
          Bind the button to a managed Bean.

          In the valueChangeListener of the SOC write the following code
          public void VCListener(ValueChangeEvent vcEvent){
            if(vcEvent.getNewValue()!=vcEvent.getOldValue()){
              <buttonBinding>.setVisible(true);
              AdfFacesContext.getCurrentInstance().addPartialTarget(<buttonBinding>);
            }
          }
          • 2. Re: Enable Button on selectOneChoice value change
            Cvele_new_account
            1. bind button to the backing bean property, for example:
               // in the backing bean (YourBean.java)
               private RichCommandToolbarButton myBtn;
            
                public void setMyBtn(RichCommandToolbarButton ctb2) {
                    this.myBtn = ctb2;
                }
            
                public RichCommandToolbarButton getMyBtn() {
                    return myBtn;
                }
            
              // in the .jspx:
                          <af:commandToolbarButton 
                                                       binding="#{yourBean.myBtn}" />
            2. make (and set) selectOneChoice valueChangeListener (YourBean.java):
                 public void mySoc_VCL(ValueChangeEvent e){
                      getMyBtn().setDisabled(false);
                     AdfFacesContext.getCurrentInstance().addPartialTarget(getMyBtn());
            
              }
            Edited by: Cvele_new_account on Nov 8, 2012 2:21 AM
            • 3. Re: Enable Button on selectOneChoice value change
              codigoadf
              Hi,
              in your button put disabled a true.
              then make a valuechangeListener in your selectoneChoice with autosubmit true.
              <af:commandButton text="commandButton 2" id="cb2" disabled="true" binding="#{MyBean.myButton}"/>
                            <af:selectOneChoice label="Label 1" id="soc1" binding="#{MyBean.button}" valueChangeListener="#{MyBean.change}" autoSubmit="true">
                              <af:selectItem label="a" value="a" id="si2"/>
                              <af:selectItem label="b" value="b" id="si3"/>
                              <af:selectItem label="c" value="c" id="si1"/>
                            </af:selectOneChoice>
                  public void change(ValueChangeEvent valueChangeEvent) {
                      //getMyButton is component binding(RichCommandButton)
                      getMyButton().setDisabled(false);
                     //refresh component
                      AdfFacesContext.getCurrentInstance().addPartialTarget(getMyButton());
                  }