PrimeUI generating repeated IDs for selectBooleanCheckbox

UI Components for JSF
Post Reply
dragongbr
Posts: 3
Joined: 05 Jul 2013, 20:29

05 Jul 2013, 21:40

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>
Last edited by dragongbr on 15 Jul 2013, 15:56, edited 1 time in total.

dragongbr
Posts: 3
Joined: 05 Jul 2013, 20:29

09 Jul 2013, 16:05

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.

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

09 Jul 2013, 17:03

dragongbr wrote:I'm sure more people already had the same problem than me.
Obviously not.

rikup
Posts: 459
Joined: 29 Jan 2013, 14:27

09 Jul 2013, 18:57

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.
PrimeNG 2.0.0
Angular 2.4.5

dragongbr
Posts: 3
Joined: 05 Jul 2013, 20:29

15 Jul 2013, 15:57

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

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

15 Jul 2013, 18:07

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.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 43 guests