1
I have a scenario that presents something weird and I don’t understand why this behavior. Using JSF with Primefaces, I have a Datatable with some (several) values that comes from the Database and are displayed in the columns. My scenario shows the following dependencies:
JSF - Primefaces (Datatable) > Managedbeans > DAOS (Methods of access to data) > Models (JPA)
My datatable looks like this:
<h:form id="form">
<p:growl id="msgs" showDetail="true" />
<p:dataTable id="calls" var="call" value="#{callMB.allCalls}" rows="25" paginator="true" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PageLinks} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="25,50,100" paginatorPosition="bottom" draggableColumns="true" scrollable="true" emptyMessage="Nenhum registro foi encontrado.">
<c:facet name="header">
Consulta de Chamadas
</c:facet>
<p:column headerText="Info" width="200" style="text-align: center">
<p:commandLink value="Ver Mais" type="button"
oncomplete="PF('callDialog').show();" update=":form:dialog">
<c:setPropertyActionListener value="#{call}"
target="#{callMB.selectedCall}"></c:setPropertyActionListener>
</p:commandLink>
</p:column>
<p:column headerText="Call ID" filterBy="#{call.callId}"
filterMatchMode="exact" width="500">
<h:outputText value="#{call.callId}"></h:outputText>
</p:column>
</p:dataTable>
<p:dialog id="dialog" header="Modal Dialog" widgetVar="callDialog"
modal="true" height="100">
<h:outputText value="#{callMB.selectedCall.callId}"></h:outputText>
</p:dialog>
</h:form>
My Managedbean is like this:
@ManagedBean
@ApplicationScoped
public class CallMB {
private List<Call> allCalls;
private Call selectedCall;
public Call getSelectedCall() {
return selectedCall;
}
public void setSelectedCall(Call selectedCall) {
this.selectedCall = selectedCall;
}
public List<Call> getAllCalls() {
allCalls = new CallDAO().retrieveAllCalls();
RouteDAO routeDAO = new RouteDAO();
for (Call call : allCalls) {
call.setRouteName(routeDAO.retrieveRouteByCode(call.getRouteCode()).getName());
}
return allCalls;
}
}
But when I click on my "See More" link it is looking for a totally different id than the one on the line.
Try adding the attribute
rowKey="#{call.callId}"
in your data table.– hebertrfreitas