1 2 Previous Next 22 Replies Latest reply: Apr 30, 2013 8:08 AM by Timo Hahn RSS

    how to disable one buuton depending on the other button behavier

    1006023
      how to disable one button depending on the other button behavior.
        • 1. Re: how to disable one buuton depending on the other button behavier
          Cvele_new_account
          Make managed bean boolean method, and make that method as Disabled property for the target button.
          • 2. Re: how to disable one buuton depending on the other button behavier
            1006023
            hi,

            if i click on one button that should disable other buttons.
            • 3. Re: how to disable one buuton depending on the other button behavier
              Cvele_new_account
              For example, you can bind that other buttons to the managed bean properties:
                  private RichCommandButton myBtn;
              
                  public void setMyBtn(RichCommandButton myBtn) {
                      this.myBtn = myBtn;
                  }
              
                  public RichCommandButton getMyBtn() {
                      return this.myBtn;
                  }
              - Then, write actionListener for button that should disable other buttons, as follows
                 
                 public void onBtnClick(ActionEvent e){
                     getMyBtn().setDisabled(true);
                    // refresh myBtn:
                    AdfFacesContext.getCurrentInstance().addPartialTarget(getMyBtn());
                  }
              • 4. Re: how to disable one buuton depending on the other button behavier
                Timo Hahn
                It would help is you tel us your jdev version.
                If you are interested you can do this without writing java code too.

                Timo
                • 5. Re: how to disable one buuton depending on the other button behavier
                  1006023
                  my jdev version is 11.1.1.6
                  • 6. Re: how to disable one buuton depending on the other button behavier
                    Timo Hahn
                    OK, you can do the following:
                    1) add a setPropertyListener on the first button which sets a variable in e.g. viewScope to false when you first click the button and true the next time like I've done for button cb2
                    or you use
                    2) add a variablt to the variable iterator of the page (check http://tompeez.wordpress.com/2013/03/25/creating-variables-and-attribute-bindings-to-store-values-temporarily-in-the-pagedef/) of type boolean (which you can initalize to 'true') which i done for cb3
                               <af:panelGroupLayout id="pgl1" layout="vertical">
                                  <af:commandButton text="commandButton 1" id="cb1" partialSubmit="true">
                                    <af:setPropertyListener from="#{viewScope.buttonstate eq false? true : false}" to="#{viewScope.buttonstate}" type="action"/>
                                    <af:setPropertyListener from="#{bindings.buttonstate1.inputValue eq false? true : false}" to="#{bindings.buttonstate1.inputValue}"
                                                            type="action"/>
                                  </af:commandButton>
                                  <af:commandButton text="commandButton 2" id="cb2" partialTriggers="cb1"
                                                    visible="#{viewScope.buttonstate eq null || viewScope.buttonstate}"/>
                                  <af:commandButton text="commandButton 3" id="cb3" partialTriggers="cb1" visible="#{bindings.buttonstate1.inputValue}"/>
                                </af:panelGroupLayout>
                    in both cases you set the partial trigger to the button you use to toggle the display (cb1). The advantage of the second solution is that you can initalize the variable ans so don't have to use the 'visible="#{viewScope.buttonstate eq null || viewScope.buttonstate}' in hte visible EL which handles the not initalized part.
                    here is the resulting page def
                    {code}<?xml version="1.0" encoding="UTF-8" ?>
                    <pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel" version="11.1.1.64.93" id="ToggleButtonPageDef" Package="de.hahn.xyzxyz.view.pageDefs">
                    <parameters/>
                    <executables>
                    <variableIterator id="variables">
                    <variable Name="buttonstate" Type="java.lang.Boolean" DefaultValue="true"/>
                    </variableIterator>
                    </executables>
                    <bindings>
                    <attributeValues IterBinding="variables" id="buttonstate1">
                    <AttrNames>
                    <Item Value="buttonstate"/>
                    </AttrNames>
                    </attributeValues>
                    </bindings>
                    </pageDefinition>
                    {code}

                    Timo
                    • 7. Re: how to disable one buuton depending on the other button behavier
                      1006023
                      hey, am not understanding..
                      • 8. Re: how to disable one buuton depending on the other button behavier
                        1006023
                        how to bind other buttons to managed bean properties,
                        • 9. Re: how to disable one buuton depending on the other button behavier
                          Cvele_new_account
                          for af:commandButton (whatever), you have the binding property in the property inspector (View --> Property inspector).
                          Focus UI component, and you will see that property.
                          Then you can set this prop. to point to managed bean method (in this case, myBtn property)
                          • 10. Re: how to disable one buuton depending on the other button behavier
                            1006023
                            is there any other method.. ?
                            look am fresher to Jdev.
                            • 11. Re: how to disable one buuton depending on the other button behavier
                              Timo Hahn
                              What don't you understand?

                              the code
                              <af:panelGroupLayout id="pgl1" layout="vertical">
                                            <af:commandButton text="commandButton 1" id="cb1" partialSubmit="true">
                                              <af:setPropertyListener from="#{viewScope.buttonstate eq false? true : false}" to="#{viewScope.buttonstate}" type="action"/>
                                              <af:setPropertyListener from="#{bindings.buttonstate1.inputValue eq false? true : false}" to="#{bindings.buttonstate1.inputValue}"
                                                                      type="action"/>
                                            </af:commandButton>
                                            <af:commandButton text="commandButton 2" id="cb2" partialTriggers="cb1"
                                                              visible="#{viewScope.buttonstate eq null || viewScope.buttonstate}"/>
                                          </af:panelGroupLayout>
                              runs without any further code. Just copy it to your page. The other (my preferred solution) is a bit more reading for you to do but works without java beans and properties too.

                              Timo
                              • 12. Re: how to disable one buuton depending on the other button behavier
                                Cvele_new_account
                                Yes, there is one.
                                Before you start anything serious, It would be helpful to meet yourself with ADF:

                                http://docs.oracle.com/cd/E16162_01/web.1112/e16182/toc.htm
                                http://docs.oracle.com/cd/E25054_01/web.1111/b31973/toc.htm
                                • 13. Re: how to disable one buuton depending on the other button behavier
                                  1006023
                                  in ur code buttonstate and buttonstate1 is unreachable
                                  • 14. Re: how to disable one buuton depending on the other button behavier
                                    Timo Hahn
                                    sorry, forgot to remove the setPropertyListener used for solution 2)
                                    GroupLayout id="pgl1" layout="vertical">
                                                  <af:commandButton text="commandButton 1" id="cb1" partialSubmit="true">
                                                    <af:setPropertyListener from="#{viewScope.buttonstate eq false? true : false}" to="#{viewScope.buttonstate}" type="action"/>
                                                  </af:commandButton>
                                                  <af:commandButton text="commandButton 2" id="cb2" partialTriggers="cb1"
                                                                    visible="#{viewScope.buttonstate eq null || viewScope.buttonstate}"/>
                                                </af:panelGroupLayout>
                                    Timo
                                    1 2 Previous Next