I have the following page:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head />
<h:form>
<p:dataTable var="organization"
value="#{organizationBean.lazyOrganizations}" paginator="true"
rows="10" lazy="true"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10,15"
selection="#{organizationBean.selectedOrganization}"
selectionMode="single" onRowSelectUpdate="display"
onRowSelectComplete="orgDialog.show()">
<f:facet name="header">
</f:facet>
<p:column headerText="Name">
<h:outputText value="#{organization.organisationName}" />
</p:column>
<p:column headerText="VAT Nr">
<h:outputText value="#{organization.vatNr}" />
</p:column>
</p:dataTable>
</h:form>
<p:dialog header="Organization Detail" widgetVar="orgDialog"
resizable="false" width="200" showEffect="explode"
hideEffect="explode">
<h:panelGrid id="display">
<h:outputText value="Name:" />
<h:outputText value="#{organizationBean.selectedOrganization.organisationName}" />
<h:outputText value="VAT Nr:" />
<h:outputText value="#{organizationBean.selectedOrganization.vatNr}" />
</h:panelGrid>
</p:dialog>
</f:view>
Code: Select all
package my.service.web;
import java.util.List;
import java.util.Map;
import org.primefaces.model.LazyDataModel;
import org.springframework.beans.factory.InitializingBean;
import my.entities.Organization;
import my.service.OrganizationService;
public class OrganizationBean implements InitializingBean {
private OrganizationService organizationService;
private Organization selectedOrganization;
private LazyDataModel<Organization> lazyOrganizations;
public Organization getSelectedOrganization() {
return selectedOrganization;
}
public void setSelectedOrganization(Organization selectedOrganization) {
this.selectedOrganization = selectedOrganization;
}
public void setOrganizationService(OrganizationService organizationService) {
this.organizationService = organizationService;
}
public LazyDataModel<Organization> getLazyOrganizations() {
return lazyOrganizations;
}
public List<Organization> getAllOrganizations(){
List<Organization> result = organizationService.getAllOrganizations();
return result;
}
public void afterPropertiesSet() throws Exception {
lazyOrganizations = new LazyDataModel<Organization>() {
private static final long serialVersionUID = 1L;
@Override
public List<Organization> load(int first, int pageSize, String sortField, boolean sortOrder, Map<String,String> filters) {
return organizationService.getOrganizations(first, pageSize);
}
};
//TODO should be set with help of projection to the real value.
lazyOrganizations.setRowCount(3500);
}
}
[*] JSF 2 (sun)
[*] Primefaces 2.2.1
[*] Portlet 2.0 / Liferay 6
[*] PortletBridge 2.0.0
The problem that I am facing now is that the row selection does not work as expected.
When I load the page and select a row that the popup shows up but has no content.
Then I press F5 and reload the page. Afterwards when I select a row the popup has content, but it has only the content of the row selected directly before the F5-hit.
This means I can press what ever I want, the content is always the one of the row that was selected before F5.
Can anybody help me out?
Best regards,
Florian