我正在尝试将我的应用程序升级到最新版本的jar,特别是我已经离开了:
JSF 2.1.12 - >> 2.2.1
Spring webflow 2.3.1 - >> 2.4.0
Primefaces 3.4.1 - >> 4.0
Spring core 3.2.0.M1
应用程序运行正常,但系统中的每个p:datatable都显示为空,默认消息“找不到记录。”,而我作为值传递的数据模型列表不为空。这是一个简单的例子:
流程:
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"
parent="GlobalMenu_subflows">
<persistence-context />
<view-state id="test" view="../views/test.xhtml">
<on-entry>
<evaluate expression="textManager.getAllTexts(brandNames)" result="viewScope.texts" result-type="dataModel"/>
<set value="'fixed'" name="viewScope.contentGroup"/>
</on-entry>
</view-state>
</flow>
textManager.getAllTexts返回TranslatedText列表。结果类型dataModel的转换器是聋人的,我没有覆盖它。
@Transactional(readOnly = true, propagation = Propagation.REQUIRED)
public List<TranslatedText> getAllTexts(String brandNames)
{
return textDao.findAllTranslatedTextByBrandNames(brandNames);
}
页面是:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui"
xmlns:sv="http://www.synaptic.com/sb"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:sf="http://www.springframework.org/tags/faces"
template="/WEB-INF/layouts/standard.xhtml">
<ui:define name="content">
<div>
<h:form id="viewForm" >
<h:panelGroup id="textFormPanel" name="textFormPanel">
<sv:csrfHidden />
<p:dataTable id="viewTable"
name="viewTable"
var="text"
rowIndexVar="rowIndex"
value="${texts}"
paginator="true"
rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
paginatorPosition="bottom"
styleClass="adminDataTable"
rowKey="#{text.id}">
<p:column filterBy="#{text.key}" filterMatchMode="contains">
<f:facet name="header">
<h:outputText value="Key" />
</f:facet>
<h:outputText value="${text.key}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Component" />
</f:facet>
<h:outputText value="${text.component}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Type" />
</f:facet>
<h:outputText value="${text.type}" />
</p:column>
</p:dataTable>
</h:panelGroup>
</h:form>
</div>
</ui:define>
</ui:composition>
在迁移之前,一切都已经过去了,我在控制台中根本没有任何错误。我正在使用eclipse进行测试,在调试中我确定TranslatedText列表已满(大约2000行)。
我检查了所有迁移指南,但找不到任何可能产生此错误的引用。我怀疑它与dataModel有关。任何人都有任何想法?
非常感谢你的帮助。
马蒂亚
####### * 编辑 * #########
我正在尝试所有可能的组合,我缩小了原因。
首先不是Primefaces问题,因为JSF h:dataTable和c:forEach也可以。但是我无法切换回之前的网络流程,因为2.4之前的任何事情都会在到达页面之前惨遭失败。
错误确实来自webflow(或来自JSF和webflow的交互),因为如果我在托管bean中移动OneSelectionTrackingListDataModel对象而不是使用webflow flowScope,一切正常。
@Component("testFlowObject")
public class TestFlowObject {
public OneSelectionTrackingListDataModel model;
public OneSelectionTrackingListDataModel getModel() {
return model;
}
public void setModel(OneSelectionTrackingListDataModel model) {
this.model = model;
}
}
<view-state id="test" view="../views/test.xhtml">
<on-entry>
<evaluate expression="textManager.getAllTexts(brandNames)" result="flowScope.texts" result-type="dataModel"/>
<evaluate expression="testFlowObject.setModel(texts)"/>
<set value="'fixed'" name="viewScope.contentGroup"/>
</on-entry>
</view-state>
现在我可以重构整个系统,如果这是一个更好的做法。但我想了解发生了什么,并尝试解决错误的原因。任何人都有任何想法?