13 Replies Latest reply: Apr 16, 2012 8:36 PM by frloopee RSS

    i find a bug about using clientListener

    frloopee
      There is a selectBooleanCheckBox in my page,and i drag a clientListener in it.
      when i click the select BooleanCheckBox, the specified javascript code will be executed.
      but when the checkBox is disabled, i click the label area,and the javascript code will also be executed.
      how can i disabled the clientListener when the checkBox is disabled.
      my jdev version:11.1.2.1.0
        • 1. Re: i find a bug about using clientListener
          Timo Hahn
          You have to check this is the javascript method. The client listener doesn't depend on the state.

          Timo
          • 2. Re: i find a bug about using clientListener
            Chris Muir-Oracle
            It would be useful if you showed us your code.

            Presumably you're using a "click" clientListener which is indeed designed to fire when the user clicks on the component, regardless if it's disabled.

            Let's take a step back. What's your use case? What are you attempting to use the clientListener for? How come you're not using the valueChangeListener on the af:selectOneChoice?

            CM.
            • 3. Re: i find a bug about using clientListener
              frloopee
              Hi,CM.
              I use the "valueChange" clientListener just now,and it works with expected result.
              But i still consider that , it is better to shut down the listener when the component is disabled.
              • 4. Re: i find a bug about using clientListener
                Chris Muir-Oracle
                When you say 'shut down the listener when the component is disabled', how is the listener activated for you? From my own testing under 11.1.2.1.0 the associated javascript does not fire with af:selectOneChoice disabled=true.

                Again can you show us the code please. Try limiting it to your af:selectOneChoice and the javascript method.

                CM.
                • 5. Re: i find a bug about using clientListener
                  frloopee
                  I'm not using the selectOneChoice, it's no problem. But i think you should try the selectBooleanCheckBox component.
                  my use case is when i click the checkBox,it will call my serverListener method.
                  the server side method is to remove all rows of a table. and disable some of other component.

                  <af:selectBooleanCheckbox value="#{bindings.singleaccidentflag.inputValue}"
                  label="#{bindings.singleaccidentflag.hints.label}"
                  id="singleHurtFlag" autoSubmit="true"
                  binding="#{backingBeanScope.backing_pages_business_regist_RegistEdit.singleHurtFlag}">
                  <af:clientListener method="disableCheckBox" type="valueChange"/>
                  <af:serverListener type="gotoServer"
                  method="#{backingBeanScope.backing_pages_business_regist_RegistEdit.clearTable}"/>
                  </af:selectBooleanCheckbox>
                  • 6. Re: i find a bug about using clientListener
                    Chris Muir-Oracle
                    Sorry I meant selectBooleanCheckbox.

                    I note you now mention a serverListener. To be clear, is the clientListener firing or the serverListener firing or both? You're original post mentioned clientListener only.

                    Can we also see your JavaScript please.

                    CM.
                    • 7. Re: i find a bug about using clientListener
                      frloopee
                      both client and server listener are firing.

                      the $$ is something like jquery selector.
                      function gotoServer(event){
                      var source=event.getSource();
                      var thirdCarValue= $$(thirdCarLossFlag").getValue();
                      var personLossValue=$$(personLossFlag").getValue();
                      var propLossValue=$$(propLossFlag").getValue();
                      var mainCarValue=$$(mainCarLossFlag").getValue();
                      var singleHurtValue=$$(singleHurtFlag").getValue();
                      var param={singleHurt:singleHurtValue,mainCar:mainCarValue,thirdCar:thirdCarValue,personLoss:personLossValue,propLoss:propLossValue};
                      AdfCustomEvent.queue(source,"gotoServer",param,false);
                      }

                      function disableCheckBox(event) {
                      var newValue = event.getSource().getValue();

                      if (newValue) {
                      $$(insertCar").setProperty('disabled', true);
                      $$(thirdCarLossFlag").setValue(false);
                      $$(personLossFlag").setValue(false);
                      $$(propLossFlag").setValue(false);
                      $$(thirdCarLossFlag").setProperty('disabled', true);
                      $$(personLossFlag").setProperty('disabled', true);
                      $$("propLossFlag").setProperty('disabled', true);
                      $$(hurtNum").setValue("");
                      $$(“deadNum").setValue("");
                      $$(”hurtNum").setProperty('disabled', true);
                      $$(“deadNum").setProperty('disabled', true);
                      $$("insertPerson").setProperty('disabled', true);
                      $$("insertProp").setProperty('disabled', true);
                      gotoServer(event);
                      }
                      else {
                      $$("thirdCarLossFlag").setProperty('disabled', false);
                      $$("personLossFlag").setProperty('disabled', false);
                      $$("propLossFlag").setProperty('disabled', false);
                      }
                      }
                      • 8. Re: i find a bug about using clientListener
                        Chris Muir-Oracle
                        The af:selectBooleanCheckbox does not have it's disabled property set to true? ie.

                        af:selectBooleanCheckbox disabled="true"

                        As such the checkbox is enabled and I would expect the client and serverListeners to fire.

                        Can you explain why this isn't the behaviour you expect please.

                        CM.
                        • 9. Re: i find a bug about using clientListener
                          frloopee
                          when the page is loading, it receives a parameter. i set the checkbox's disabled value according to
                          the parameter. if it is 'read' then the checkBox is disabled.
                          • 10. Re: i find a bug about using clientListener
                            Chris Muir-Oracle
                            Code please.

                            However I already suspect what you're doing. Are you using the ADF JavaScript APIs for disabling the item?

                            CM.
                            • 11. Re: i find a bug about using clientListener
                              frloopee
                              <af:clientListener method="init" type="load"/>
                              function init(){
                              var editFlag='${param.editFlag}';
                              if(editFlag=="readOnly"){
                              $$("singleHurtFlag").setProperty("disabled",true);
                              }
                              }
                              i've set the "unsecure" property as "disabled". so i can use javascript to set the disabled property.
                              • 12. Re: i find a bug about using clientListener
                                Chris Muir-Oracle
                                The mistake here is to think JQuery can be used to manipulate the ADF components so readily, it wasn't designed to work with JQuery (it in fact predates JQuery). To work with the ADF components we use the ADF JavaScript APIs. They are documented here: http://docs.oracle.com/cd/E24382_01/apirefs.1112/e17489/toc.htm

                                You'll note for the selectBooleanCheckbox: http://docs.oracle.com/cd/E24382_01/apirefs.1112/e17489/toc.htm ... that there is no setDisabled method. Why? As described in the getDisabled doc:

                                "Get function for attribute for 'disabled'. This attribute is secured. You may get it, but you may not set it. Any changes to this attribute will not be transmitted to the server."

                                The solution is to work with the server to disable the selectBooleanCheckbox.

                                Further to this I wouldn't use the onload clientListener. Instead I'd be using the "bookmark" facility provided by the ADF controller as described here: http://docs.oracle.com/cd/E24382_01/web.1112/e16182/taskflows_activities.htm#BABHAAED

                                Presumably you are using the ADF Controller (adfc-config.xml, task flows etc) rather than just raw ADF Faces components and JQuery?

                                CM.
                                • 13. Re: i find a bug about using clientListener
                                  frloopee
                                  yes,you're right.And thanks for your reply.
                                  it helps me a lot .