2 Replies Latest reply on Feb 3, 2010 6:42 AM by nbelaevski

    Getting element id inside of rich:column

    dkim18
      Hi

       

      I am trying to get element id this is inside of rich:column. If I take selectBooleanCheckbox out of rich:column, it works. (This only works in Firefox not IE.) So, it is not working inside of rich:column. I googled and tried, but wasn't successful.

       

      So, my questions are:
      1. how do I get element id inside of rich:column?
      2. why this doesn't work even outside of rich:column in IE?

       

      thx,

       

      -----------------------------------------------------------------------
      <h:form id="kpata" styleClass="edit">
      ...
      ...
      <h:selectBooleanCheckbox  value="#{quanChkBoxBean.kpataAllQ1}" id="kpataAllQ1" onclick="quanChkBox();"/> Select All Q1
      ...
      ...

       

      <rich:column>
           <h:selectBooleanCheckbox id="kpataCherokeeG1Q1"  value="#{quanChkBoxBean.kpataCherokeeG1Q1}" /><b/>
            <h:outputText value="Cherokee" />
        </rich:column>

       

      +++++++++++++++

       


      function quanChkBox(){
                                               if(document.getElementById('kpata:kpataAllQ1').checked==true){
                                                       document.getElementById('kpata:kpataCherokeeG1Q1').disabled = true;
      ...
      ...

       

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

      I found followings:

      this works since this is outside of rich:column:
      if (#{rich:element('kpata:kpataAllQ1')}.checked==true) {
              #{rich:element('kpata:kpataAllQ1')}.disabled = true;
      }


      but this doesn't work. (maybe this is inside of rich:column?)
      if(document.getElementById('kpata:kpataAllQ1').checked==true){
         alert("test2");          
         #{rich:element('kpata:kpataCherokeeG1Q1')}.checked = true;
        }

      ----

      anyway, rich:column causing problem and this seems obvious so far.

        • 1. Re: Getting element id inside of rich:column
          liuliu

          hi,

           

          i think the id generated of your checkbox is not kpata:kpataCherokeeG1Q1. if you use firebug you can find a row index number is inserted in the id of your checkbox .

           

           

          liu

          • 2. Re: Getting element id inside of rich:column
            nbelaevski
            That's right. I guess topic-starter uses some kind of data table, not standalone rich:column component. So, for the case of data table there are check boxes generated for table rows and each has a special ID, so you won't be able to address them without coding some kind of cycle. I suggest to use jQuery for this case, take a look at rich;jQuery component.