DataTable with CheckBox jsf

Asked by on 2013-04-03T15:32:56-04:00
I have a dataTable with a checkbox column. The data from dataTable I load the database. So far everything is going well. I need that in a certain condition appear some checkbox marked, as I do this?

Following the dataTable code:

<p:dataTable id="dataTable" var="valor" 
 style="width:100%; text-align:center"
 value="#{beanMensagemXContato.dataModelMsg}"
 paginator="true" rows="5" 
 paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
 rowsPerPageTemplate="5,10,15"
 selection="#{beanMensagemXContato.selectedMensagens}">



 <f:facet name="header"> 
 Mensagens 
 </f:facet> 

 <p:column selectionMode="multiple" style="width:5%">

 </p:column> 

 <p:column>
 <f:facet name="header">
 <h:outputText value="Código" />
 </f:facet>
 <h:outputText value="#{valor.idtMensagem}" />
 </p:column>

 <p:column>
 <f:facet name="header">
 <h:outputText value="Mensagem" />
 </f:facet>
 <h:outputText value="#{valor.nomMensagem}" />
 </p:column>

 <p:column>
 <f:facet name="header">
 <h:outputText value="Descrição" />
 </f:facet>
 <h:outputText value="#{valor.desMensagem}" />
 </p:column>

 <p:column>
 <f:facet name="header">
 <h:outputText value="Configurador" />
 </f:facet>
 <h:outputText value="#{valor.indConfigurador}" />
 </p:column>
 </p:dataTable>

Best Answer

Answered by on 2013-04-03T16:47:44-04:00
Haven't worked with primefaces selection column, but...

INMO you should add the needed element/s into the selectedMensagens , selectedMensagens should represent the selected rows... , do that logic on server side (in @PostConstruct for example), if a certain element from dataModelMsg meet the condition, you should add it to selectedMensagens

Your Answer
No advertising and No spamming please.
Name:
Answer: