我有一个在 Jboss 6 上使用 Primefaces 3.5 和 Omnifaces 1.5 的应用程序,使用 myfaces 2.1.5
尝试使用o:converter
我收到以下错误。
org.omnifaces.taghandler.Converter
viewId=/xhtml/propelModules/initiatePropel.xhtml
location=C:\jboss-6.1.0.Final\server\default\deploy\PropelEAR.ear\PropelWeb.war\xhtml\propelModules\initiatePropel.xhtml
phaseId=RENDER_RESPONSE(6)
Caused by:
java.io.NotSerializableException - org.omnifaces.taghandler.Converter
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
相关代码是...
<p:selectManyCheckbox value="#{initiatePropelManagedBean.currentWon.selectedEmployeeList}"
layout="pageDirection">
<o:converter converterId="omnifaces.ListIndexConverter"
list="#{initiatePropelManagedBean.currentWon.employeeList}" />
<f:selectItems value="#{initiatePropelManagedBean.currentWon.employeeList}"
var="emp" itemLabel="#{emp}" itemValue="#{emp}" />
<p:ajax process="@this" update="employeeCount"></p:ajax>
</p:selectManyCheckbox>
我可以重现你的问题。这是 MyFaces 2.1.5 中的一个错误。我找不到相关的错误报告和修复版本,但我至少可以看出这个构造对我来说在当前最新的 MyFaces 2.1.12 上工作得很好。因此,升级 MyFaces 也应该适合您。
无关就具体问题而言,这里的转换策略有些奇怪。只需使用omnifaces.SelectItemsConverter
or omnifaces.SelectItemsIndexConverter
(如果你没有好的equals()
on the Employee
实体)应该就足够了。
<p:selectManyCheckbox ... converter="omnifaces.SelectItemsIndexConverter">
<f:selectItems value="#{initiatePropelManagedBean.currentWon.employeeList}" />
</p:selectManyCheckbox>
The SelectItems(Index)Converter
并不严格要求List<SelectItem>
作为模型,它只需要一个<f:selectItem(s)>
视图中。这List(Index)Converter
适用于不使用的组件<f:selectItem(s)>
, 例如<p:autoComplete>
, <p:picklist>
, etc.
如果您由于某种原因无法升级 MyFaces,这将是替代解决方案。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)