6 Replies Latest reply on Mar 26, 2013 12:13 PM by sarfraz

    checkbox valueChangeListener value

      Hi guys,
      I have a situation in which I have to render some components based on value of two checkboxes.I have called a function on value change of both checkbox using valuechangelistener.But the thing is that at a time I could get hold of value of only one checkbox.How can I get hold of both the checkboxes at the same time in my function.
        • 1. Re: checkbox valueChangeListener value

          can you try by getting hold of other checkbox either having a binding to backing bean or traversing the tree to get hold of second check box.

          • 2. Re: checkbox valueChangeListener value
            In the valueChangeListener, you will get the value of the checkbox for which the value is called. You need to separately refer the value of second checkbox. Now accessing the value depends on how you have binded your checkbox -

            a) if your value is binded to bean variable, refer to that variable value.
            b) if it is binded to some VO attribute, refer to attributeBinding value using ADFUtil.getAttributeBinding("attrBindingName") --- Standard method to access attributeBinding value using bindings in ADF.

            • 3. Re: checkbox valueChangeListener value
              Vineet Singh-Oracle

              Can you please elaborate more on use case?

              If your checkbox value is coming from same VO, i am not sure why you want to have access to both at same time, but you can always set some count on number of checkboxes selected, by putting count in some viewScope or PageFlowScope, whatever you would like to use.
              Or just do setAttribute and check for checked ones.

              • 4. Re: checkbox valueChangeListener value
                try using js like,

                add clientListener to both check boxes...

                <af:clientListener type="valueChange"

                <af:resource type="javascript">
                function renderComponent(event) {
                var source = event.getSource();
                if (source.getValue() == true) {
                var allVars = new Array("sbc1", "sbc2");
                for (i = 0; i &lt; allVars.length; i++) {
                var cb = source.findComponent(allVars);
                if (cb.getId() != source.getId()) {
                //do something.....
                • 5. Re: checkbox valueChangeListener value
                  Hi Sarfraz,

                  Please use same valuechangelistener for both checkbox components.
                  It is already working for me and hope It will work for you.
                  af:selectBooleanCheckbox text="selectBooleanCheckbox 1" label="Label 1" id="sbc1"
                  valueChangeListener="#{test.chkchangeltsen}" autoSubmit="true"/>
                  <af:selectBooleanCheckbox text="selectBooleanCheckbox 2" label="Label 2" id="sbc2" valueChangeListener="#{test.chkchangeltsen}"


                  Edited by: 812903 on Mar 24, 2013 11:57 PM

                  Edited by: 812903 on Mar 24, 2013 11:58 PM
                  • 6. Re: checkbox valueChangeListener value
                    Thanku all guys..but I tried a much easier solution rather than javascript and bindings..I have made my variables static in the bean and individually getting the values for both the checkboxes...