Page 1 of 1

PrimeUI generating repeated IDs for selectBooleanCheckbox

Posted: 05 Jul 2013, 21:40
by dragongbr
Hello PrimeUI experts.

I have a issue with primefaces generating repeated IDs for checkboxes.
I have 2 guys, one with 2 tests and other with 4 tests.
When I list them using subTable (http://www.primefaces.org/showcase/ui/d ... bTable.jsf) the ID that primefaces generates for each checkbox is based on the checkbox position under the person.
That means each first person test will have an ID as zero, the second as 1, the third as 2...

Below is an screenshot of the first test of each person being highlighted when I just pass the mouse over anyone of the first checkboxes.
Image
The same happens when I pass mouse over the second test checkbox, the checkbox that is in second position of each person is highlighted.

How can I generate dynamic checkbox IDs?

I tryied to set id="#{test.testId}" but all just crashes when I do that...

Is this a PrimeFaces bug?

XHTML code:

Code: Select all

<p:dataTable id="sorotable" 
                                     style="text-align: center; width: 806px; margin-top: 5px; margin-left: -15px !important;" 
                                     rowKey="#{e.resExameCmDcId}" 
                                     styleClass="list" tableStyleClass=" list2 list-table mg-leftless5"   
                                     value="#{cc.attrs.exameAccordion.exameCMDCBean.pessoasCMDC}" var="pessoaCMDC" paginator="false" 
                                     emptyMessage="#{global['global.mensagem.vazio']}" >
                        
                            <p:columnGroup type="header">  
                                <p:row>  
                                    <p:column headerText="Checkbox" />  
                                    <p:column headerText="Soro" />  
                                    <p:column headerText="PRA AGH c/DIT" />  
                                    <p:column headerText="PRA AGH s/DIT" />  
                                    <p:column headerText="PRA Quali I" />  
                                    <p:column headerText="PRA Quali II" />  
                                    <p:column headerText="PRA Quanti I" />  
                                    <p:column headerText="PRA Quanti II" />  
                                </p:row>  
                            </p:columnGroup> 
                            <p:subTable id="subtable" var="exame" value="#{pessoaCMDC.exameCMDC}">
                                <f:facet name="header">
                                    <p:column style="text-align: center; min-width: 0px; width: 200px;">
                                        <h:outputText value="#{pessoaCMDC.nome} "/>
                                    </p:column>
                                    <p:column style="text-align: center; min-width: 0px; width: 70px"> 
                                        <h:outputText value="  - RGCT: #{pessoaCMDC.rgct} "/>
                                    </p:column> 
                                </f:facet>

                                
                                <p:column style="text-align: center;">
                                    <p:selectBooleanCheckbox 
                                                             value="#{exame.selected}" 
                                                             disabled="#{(exame.resExameCmDcId==null?false:true) or (cc.attrs.exameAccordion.disableEdicao)}">
                                        <p:ajax listener="#{exameCMDCMBean.processSoroSelection}"  />
                                        <f:attribute name="selres" value="#{pessoaCMDC.exameCMDC}" />
                                        <f:attribute name="ex" value="#{cc.attrs.exameAccordion}" />
                                    </p:selectBooleanCheckbox>
                                    
                                </p:column>
                                
                                <p:column style="text-align: center;min-width: 0px; width: 120px">
                                    <h:outputText value="#{exame.soroId.nomeAmostra}"/>
                                </p:column>
                                <p:column style="text-align: center;min-width: 0px; max-width: 80px; min-width: 20px;">  
                                    <h:outputText value="#{exame.praAghSemDTT}"/>
                                </p:column>
                                <p:column style="text-align: center;min-width: 0px; max-width: 80px; min-width: 20px;">  
                                    <h:outputText value="#{exame.praAghComDTT}"/>
                                </p:column>
                                <p:column style="text-align: center;min-width: 0px; min-width: 20px;">  
                                    <h:outputText value="#{exame.praQualiI}"/>
                                </p:column>
                                <p:column style="text-align: center;min-width: 0px; min-width: 20px;">  
                                    <h:outputText value="#{exame.praQualiII}"/>
                                </p:column>
                                <p:column style="text-align: center;min-width: 0px; min-width: 20px;">  
                                    <h:outputText value="#{exame.praQuantiI}"/>
                                </p:column>
                                <p:column style="text-align: center;min-width: 0px; min-width: 20px;">  
                                    <h:outputText value="#{exame.praQuantiII}"/>
                                </p:column>
                            </p:subTable> 
                           
                            <p:columnGroup type="footer"/>
                           
                            
                        </p:dataTable>

Re: PrimeUI generating repeated IDs for selectBooleanCheckbo

Posted: 09 Jul 2013, 16:05
by dragongbr
I'm sure more people already had the same problem than me.
That is a basic thing in PrimeFaces.

If someone can help, I would be glad.

Re: PrimeUI generating repeated IDs for selectBooleanCheckbo

Posted: 09 Jul 2013, 17:03
by kukeltje
dragongbr wrote:I'm sure more people already had the same problem than me.
Obviously not.

Re: PrimeUI generating repeated IDs for selectBooleanCheckbo

Posted: 09 Jul 2013, 18:57
by rikup
Post your xhtml, version info, then others might be able to help you more. But two things are quite sure here:
I tryied to set id="#{test.testId}" but all just crashes when I do that...
This will most likely not work because of how ids are assigned and how iterating components work. You can Google for JSF dynamic id and you will probably get results for why it won't work.

Code: Select all

Is this a PrimeFaces bug?
In 99,99999999% of cases it's not.

TLDR: post code and version infos.

Re: PrimeUI generating repeated IDs for selectBooleanCheckbo

Posted: 15 Jul 2013, 15:57
by dragongbr
I've posted the XHTML code of the part that is not working.

Did someone experienced the same issue? That is driving me crazy. :P

Re: PrimeUI generating repeated IDs for selectBooleanCheckbo

Posted: 15 Jul 2013, 18:07
by smithh032772
Evidently, you need to look at the PrimeFaces showcase example for Subtable, and use the 'same' code that you see in the showcase example, take that code, create a small test case (project) in your IDE, copy/paste the subtable showcase example code (xhtml and bean), and then add p:selectBooleanCheckbox (and keep it very very simple), and that will help you 'learn' how to use and add selectBooleanCheckbox to subtable, and then after you do this, come back here and let us know what changes you made to your code to get it working.

Of course, you better pay attention to everything in rikup's earlier response, and modify your code, accordingly.