MyFaces 2.2.6
IBM WebSphere ND 7.0.0.23, ARIESJPA 1.0.0.7
Java version = JRE 1.6.0 IBM J9 2.4
Linux amd64-64
TL;DR: view a LazyDataTable, filter the data, use a contextMenu to navigate to a different view, click the back button, the LazyDataTable loads backup showing all rows but no detail data is displayed.
I was able to reproduce this issue using the Showcase and 5.1.6. I am not sure if this is an issue with PF, JSF/MyFaces or me (the latter is very plausible if not probable.) I pulled down the code for the Lazy Data model showcase (http://www.primefaces.org/showcase/ui/d ... lazy.xhtml) from SVN (https://code.google.com/p/primefaces/so ... yView.java) and then made some changes:
* Adding debugging System.out.println statements
* Added a contextMenu for the dataTable with an action
* Added a filteredValue attribute to the dataTable
* Added an action that does a faces-redirect to a different view
The steps to reproduce the error are:
* Load the default index.xhtml page (Chrome 39.0.2171.95 m)
* filter any row by any value
* click on any row, verify that the car details are displayed
* right-click on the contextMenu and click on "View Detals"
* hellowWorld.xhtml is displayed
* hit the back button
* verify that the index.xhtml is displayed (with the LazyCarDataModel.load() being called)
* click on any row, verify that the car details are now BLANK (expected value would be the car details.)
Here is the SystemOut.log file (with my comments to add clarity)
Code: Select all
==>Load the default index.xhtml page
[12/18/14 9:28:43:812 EST] 00000057 SystemOut O Loading the Lazy Data Model
[12/18/14 9:28:43:814 EST] 00000057 SystemOut O getting selectedCar
[12/18/14 9:28:43:819 EST] 00000057 SystemOut O getting selectedCar
==> Filter by "a" in the Id
[12/18/14 9:29:25:542 EST] 0000005e SystemOut O getting filtered values
[12/18/14 9:29:25:545 EST] 0000005e SystemOut O setting selectedCar
[12/18/14 9:29:25:546 EST] 0000005e SystemOut O setting filtered values
[12/18/14 9:29:25:546 EST] 0000005e SystemOut O Loading the Lazy Data Model
[12/18/14 9:29:25:547 EST] 0000005e SystemOut O getting selectedCar
==>Click on any row to view car details (which are correctly shown)
[12/18/14 9:29:52:729 EST] 0000005b SystemOut O getting filtered values
[12/18/14 9:29:52:732 EST] 0000005b SystemOut O setting selectedCar
[12/18/14 9:29:52:733 EST] 0000005b SystemOut O getting selectedCar
[12/18/14 9:29:52:733 EST] 0000005b SystemOut O getting selectedCar
[12/18/14 9:29:52:733 EST] 0000005b SystemOut O getting selectedCar
[12/18/14 9:29:52:733 EST] 0000005b SystemOut O getting selectedCar
[12/18/14 9:29:52:733 EST] 0000005b SystemOut O getting selectedCar
[12/18/14 9:29:52:735 EST] 0000005b SystemOut O getting selectedCar
[12/18/14 9:29:52:735 EST] 0000005b SystemOut O getting selectedCar
[12/18/14 9:29:52:735 EST] 0000005b SystemOut O getting selectedCar
[12/18/14 9:29:52:736 EST] 0000005b SystemOut O getting selectedCar
[12/18/14 9:29:52:736 EST] 0000005b SystemOut O getting selectedCar
==>Right-click on any row and select View Detials
[12/18/14 9:30:34:361 EST] 0000005b SystemOut O getting filtered values
[12/18/14 9:30:34:361 EST] 0000005b SystemOut O getting selectedCar
[12/18/14 9:30:34:364 EST] 0000005b SystemOut O getting selectedCar
[12/18/14 9:30:34:365 EST] 0000005b SystemOut O setting selectedCar
[12/18/14 9:30:34:365 EST] 0000005b SystemOut O getting selectedCar
[12/18/14 9:30:34:366 EST] 0000005b SystemOut O faces-redirect
==>Click the back button
[12/18/14 9:31:08:858 EST] 0000005c SystemOut O Loading the Lazy Data Model
[12/18/14 9:31:08:862 EST] 0000005c SystemOut O getting selectedCar
[12/18/14 9:31:08:868 EST] 0000005c SystemOut O getting selectedCar
==>Click on any row to view details, which are BLANK
[12/18/14 9:31:23:978 EST] 00000057 SystemOut O getting filtered values
[12/18/14 9:31:23:980 EST] 00000057 SystemOut O setting selectedCar
index.xhtml
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions"
xmlns:c="http://java.sun.com/jstl/core">
<h:head>
<title>PF_BUG_TEST_20141217</title>
</h:head>
<f:view contentType="text/html" locale="en" >
<h:body>
<h:form id="form">
<p:contextMenu for="carTable" id="contextMenuId" widgetVar="contextMenuWidget">
<p:menuitem value="View Details" update="@all" icon="ui-icon-extlink" action="#{dtLazyView.viewDetails}" />
</p:contextMenu>
<p:dataTable var="car" value="#{dtLazyView.lazyModel}" paginator="true" rows="10"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10,15" selectionMode="single" selection="#{dtLazyView.selectedCar}" id="carTable" lazy="true" filteredValue="#{dtLazyView.filteredValue }">
<p:ajax event="rowSelect" listener="#{dtLazyView.onRowSelect}" update=":form:carDetail" oncomplete="PF('carDialog').show()" />
<p:column headerText="Id" sortBy="#{car.id}" filterBy="#{car.id}">
<h:outputText value="#{car.id}" />
</p:column>
<p:column headerText="Year" sortBy="#{car.year}" filterBy="#{car.year}">
<h:outputText value="#{car.year}" />
</p:column>
<p:column headerText="Brand" sortBy="#{car.brand}" filterBy="#{car.brand}">
<h:outputText value="#{car.brand}" />
</p:column>
<p:column headerText="Color" sortBy="#{car.color}" filterBy="#{car.color}">
<h:outputText value="#{car.color}" />
</p:column>
</p:dataTable>
<p:dialog header="Car Detail" widgetVar="carDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false">
<p:outputPanel id="carDetail" style="text-align:center;">
<p:panelGrid columns="2" rendered="#{not empty dtLazyView.selectedCar}" columnClasses="label,value">
<f:facet name="header">
<p:graphicImage name="demo/images/car/#{dtLazyView.selectedCar.brand}-big.gif"/>
</f:facet>
<h:outputText value="Id:" />
<h:outputText value="#{dtLazyView.selectedCar.id}" />
<h:outputText value="Year" />
<h:outputText value="#{dtLazyView.selectedCar.year}" />
<h:outputText value="Color:" />
<h:outputText value="#{dtLazyView.selectedCar.color}" style="color:#{dtLazyView.selectedCar.color}"/>
<h:outputText value="Price:" />
<h:outputText value="#{dtLazyView.selectedCar.price}">
<f:convertNumber type="currency" currencySymbol="$" />
</h:outputText>
</p:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
</h:body>
</f:view>
</html>
Code: Select all
package org.primefaces.showcase.view.data.datatable;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.SelectEvent;
import org.primefaces.model.LazyDataModel;
import org.primefaces.showcase.domain.Car;
import org.primefaces.showcase.service.CarService;
@ManagedBean(name="dtLazyView")
@ViewScoped
public class LazyView implements Serializable {
private static final long serialVersionUID = 1L;
private LazyDataModel<Car> lazyModel;
private LazyDataModel<Car> filteredValue;
private Car selectedCar;
@ManagedProperty("#{carService}")
private CarService service;
@PostConstruct
public void init() {
lazyModel = new LazyCarDataModel(service.createCars(200));
}
public LazyDataModel<Car> getLazyModel() {
return lazyModel;
}
public Car getSelectedCar() {
System.out.println("getting selectedCar");
return selectedCar;
}
public void setSelectedCar(Car selectedCar) {
System.out.println("setting selectedCar");
this.selectedCar = selectedCar;
}
public void setService(CarService service) {
this.service = service;
}
public void onRowSelect(SelectEvent event) {
FacesMessage msg = new FacesMessage("Car Selected", ((Car) event.getObject()).getId());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
public String viewDetails() {
System.out.println("faces-redirect");
return "helloWorld?faces-redirect=true";
}
public LazyDataModel<Car> getFilteredValue() {
System.out.println("getting filtered values");
return filteredValue;
}
public void setFilteredValue(LazyDataModel<Car> filteredValue) {
System.out.println("setting filtered values");
this.filteredValue = filteredValue;
}
}
LazySorter.java
LazyCarDataModel.java (ok I added a System.out.println but other then that not changed)
CarService.java
Car.java
hellowWorld.xhtml is basic XHTML file that just displays "Hello World"
and in case you want it here is the web.xml
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>PF_BUG_TEST_20141217</display-name>
<context-param>
<param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.SUPPORT_JSP_AND_FACES_EL</param-name>
<param-value>false</param-value>
</context-param>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
<url-pattern>/faces/*</url-pattern>
<url-pattern>*.xhtml</url-pattern>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.xhtml</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
My question/issue is why is the detail blank when the datatable is displayed in the browser and I can see that the load() method being called to populate the data?
Please let me know if there are any additional details that would help/assist.
Thanks in advance!!