0 Replies Latest reply on Oct 21, 2010 10:03 AM by shikida

    How to refer to a item of a SelectManyCheckbox programmatically

    shikida

      Hi

       

      I am trying to generate programmatically this

       

      HtmlJQuery jq = (HtmlJQuery)application.createComponent(HtmlJQuery.COMPONENT_TYPE);
      jq.setSelector(target);

       

      The problem is that the target is one item of a selectManyCheckbox

       

      I can´t find how to set individual IDs for each item, since SelectItem does not have such a method. Instead, it seems to always generate an ID like

       

      form:id:1

      form:id:2

      form:id:3

      ...

       

      if I set target = "id:2", it generates a javascript like

       

      function xxx(elm, param) {
           var selector = "#form\\:id:2";
           try {
                selector = eval("#form\\:id:2");
           } catch (e) {}
           
           jQuery(elm || selector).attr( 'disabled' , 'disabled'  );
      }

       

      but it obviously does not work, because jquery would understand

       

                selector = eval("#form\\:id\\:2");

      and if I set target="id\\\\:2"

      it generates

                selector = eval("#form\\:id\\\\:2");

      and if I set target="id\\:2"

      it raises

      javax.faces.component.UIComponentBase.findComponent(UIComponentBase.java:612)

      ps. notice that if I manually insert the following javascript in the page with
                selector = eval("#form\\:id\\:2");

      the script just works.

      Any ideas?

      TIA

      Leo K.