12 Replies Latest reply: May 21, 2012 2:14 AM by 935450 RSS

    SelectManyCheckbox event handling

    935450
      Hi,
      I am new to this ADF technologies. In my jsp i have a selectmanycheckbox component and have a event handler method in backingbean, when i am clicking on the checkbox the control is going to
      event handler method in backing bean, its fine and working..
      My question is where the control is going or which method is invoking when i am unchecking the same check box ,its not coming to same event handler




      Any help is appreciated...

      Thanks in advance..

      Anoop C
        • 1. Re: SelectManyCheckbox event handling
          umesh.agarwal
          Generally when you select/unselect a check box, a valueChangeListener gets fired. There is a valueChangeListener property in the component, SelectManyCheckBox. You can bind a managed bean method with this.
          Dont forget to put autosubmit=true.
          • 2. Re: SelectManyCheckbox event handling
            935450
            Yes. i have given valueChageListener method and autosubmit=true and when i select a checkbox valuechangelistener method is invoking.
            But when i unselect checkbox its not going to valuechangelistener method.
            • 3. Re: SelectManyCheckbox event handling
              Sudipto Desmukh
              Please post your jspx code and ValuChangeListener code
              • 4. Re: SelectManyCheckbox event handling
                935450
                my jsp code
                *****************

                <af:selectOneChoice onchange="return fnCheck()"           id="financialYearId" binding="#{acctSummaryBB.financialYears}"
                     valueChangeListener="#{acctSummaryBB.getSelectedFinancialYear}"      autoSubmit="true" >
                     <f:selectItems binding="#{acctSummaryBB.financialYear}" />
                </af:selectOneChoice>

                     <af:selectManyCheckbox id="BU" onclick="selectAllBU()" immediate="true" valuePassThru="true" autoSubmit="true"
                value="#{acctSummaryBB.selectedBUs}" valueChangeListener="#{acctSummaryBB.triggerBU}" >
                               <f:selectItem itemValue="ALL" itemLabel="ALL" />
                               <f:selectItems value="#{acctSummaryBB.allBU}" />
                     </af:selectManyCheckbox>

                My BackingBean Code
                ********************




                public void triggerBU(ValueChangeEvent evt)
                {

                int FY = 0;
                String str = "";

                if (evt != null)
                {
                FacesMessage fm;
                System.out.println("##################### BU CHANGE START####################");
                selectedBUs = ((List)evt.getNewValue());

                System.out.println("##################### SELECTED BU===" + selectedBUs);

                }
                }

                public void getSelectedFinancialYear(ValueChangeEvent event)
                {

                System.out.println("############### START OF FIN YEAR CHANGE METHOD ##################### ");

                }



                ***************************************************************

                Every time control is going to getSelectedFinancialYear() after invoking triggerBU() method when i am checking one item from the SelectManyCheckBox.

                Can anybody provide a solution for this...How can i stop firing ValueChangeEvent from selectOneChoice .

                Plz..Provide a solution.....Thanks..
                • 5. Re: SelectManyCheckbox event handling
                  raphael rodrigues - oracle
                  Have you tested with immediate="false" ?

                  It's possible to cause collateral damage...

                  Regards,
                  • 6. Re: SelectManyCheckbox event handling
                    935450
                    Nope.....tried with immediate=false Not working.........
                    • 7. Re: SelectManyCheckbox event handling
                      Tulasi Kamodula
                      Try removing onchange="return fnCheck()" and onclick="selectAllBU()" on the components and test.

                      Thanks,
                      TK
                      • 8. Re: SelectManyCheckbox event handling
                        Sudipto Desmukh
                        Anoop a similar issue was logged by you a few days back - Re: selectmanycheckbox  rendering issue
                        You didnot mention what caused the issue & what was the solution - in all probability the root cause either is the same or has not been addressed.

                        In addition to what Tulasi mentioned .. please follow the standards/recommended approach to use Javascript in ADF applications using ClientListener , <af:resource> tag etc. instead of the way you did.
                        http://www.oracle.com/technetwork/developer-tools/jdev/1-2011-javascript-302460.pdf
                        https://blogs.oracle.com/jdevotnharvest/entry/gotcha_when_using_javascript_in

                        Concepts and more - http://download.oracle.com/otn_hosted_doc/jdeveloper/11gdemos/adf-insider-javascript/adf-insider-javascript.html
                        • 9. Re: SelectManyCheckbox event handling
                          935450
                          Anyway to remove/add ValueChangeListener programically from the Backing Bean..
                          • 10. Re: SelectManyCheckbox event handling
                            Sudipto Desmukh
                            Did you try what Tulasi suggested and I raised ?
                            • 11. Re: SelectManyCheckbox event handling
                              935450
                              Thanks..Tried by removing onclick, onchange methods....still its not working..


                              I am binding CoreSelectOneChoice object in jsp and setting values from Backing Bean using Hashmap

                              Code :
                              *********

                              if (financialYears == null)
                              financialYears = new CoreSelectOneChoice();
                              if (financialYear == null)
                              financialYear = new UISelectItems();
                              int currentYear = Calendar.getInstance().get(1);
                              Map yearsMap = new LinkedHashMap();
                              int index = 0;
                              for (int i = 2011; i <= currentYear; ++i) {
                              yearsMap.put(i + " - " + (i + 1), Integer.valueOf(i));
                              if (i == Integer.parseInt(defaultFinYear)) {
                              financialYears.setValue(defaultFinYear);
                              financialYears.setSubmittedValue(Integer.valueOf(index));
                              }
                              ++index;
                              }
                              this.financialYear.setValue(yearsMap);


                              I think when i am calling financialYears.getValue() method it automatically fires ValueChangeListener..
                              • 12. Re: SelectManyCheckbox event handling
                                935450
                                onchange="return fnCheck()" and onclick="selectAllBU()" these method is returns only true or false based on validation...