我们有一个碰撞实体列表,您可以在 PrimeFaces 中单选<p:datatable>
。下面是一个显示相关历史记录和文件附件的字段集。
这是 JSF 页面(附件数据表比其他数据表更重要):
<h:panelGrid>
<p:scrollPanel mode="native">
<p:dataTable value="#{collisionManager.selectedCollisions}"
var="cln"
selection="#{collisionManager.selectedStateChangeCollision}"
selectionMode="single"
rowKey="#{cln.id}"
paginator="true"
paginatorPosition="bottom"
rows="5">
<p:ajax event="rowSelect" process="@this" update="@form" />
<p:column headerText="ID">
<h:outputText value="#{cln.id}" />
</p:column>
...
</p:dataTable>
</p:scrollPanel>
<p:fieldset legend="History and Attachments">
<p:tabView widgetVar="stateChangeTabView"
dynamic="true"
cache="false">
<p:tab title="History">
...
</p:tab>
<p:tab title="Attachments">
<p:dataTable id="attachments-datatable"
value="#{attachmentManager.activeAttachments}"
var="att"
paginator="true"
paginatorPosition="bottom"
rows="3">
<p:column headerText="File Name">
<h:outputText value="#{att.fileName}" />
</p:column>
<p:column headerText="Deleted">
<h:outputText value="#{att.deleted}" />
</p:column>
<p:column headerText="Marked">
<h:outputText value="#{attachmentManager.markedToDelete(att)}" />
</p:column>
<p:column headerText="Actions">
<p:commandButton icon="ui-icon ui-icon-trash"
title="Mark to delete"
action="#{attachmentManager.markToDelete(att)}"
process="@this"
update="@form"
rendered="#{not attachmentManager.markedToDelete(att)}">
</p:commandButton>
<p:commandButton icon="ui-icon ui-icon-cancel"
title="Unmark to delete"
action="#{attachmentManager.unmarkToDelete(att)}"
process="@this"
update="@form"
rendered="#{not attachmentManager.markedToDelete(att)}">
</p:commandButton>
</p:column>
</p:dataTable>
</p:tab>
</p:tabView>
</p:fieldset>
</h:panelGrid>
<!-- SAVE + CANCEL buttons here -->
这是bean(在类路径中AttachmentManager
有 Seam 3 Faces以便兼容,在这里应该无关紧要):@Named
@Viewscoped
@Named
@ViewScoped
public class AttachmentManager implements Serializable
{
// attachments to be deleted
private List<Attachment> markedAttachments;
public void markToDelete( Attachment attachment )
{
if ( !this.markedAttachments.contains( attachment ) )
{
this.markedAttachments.add( attachment );
}
}
public void unmarkToDelete( Attachment attachment )
{
this.markedAttachments.remove( attachment );
}
public boolean markedToDelete( Attachment attachment )
{
return this.markedAttachments.contains( attachment );
}
}
当评估行中页面中的表达式时问题开始(附件表):
<h:outputText value="#{attachmentManager.markedToDelete(att)}" />
上面代码中的哪个表达式实际上被执行并不重要,它们基本上都失败了:
javax.el.ELException: /view/changeData.xhtml @184,102 value="#{not attachmentManager.markedToDelete(att)}": java.lang.ClassCastException: com.company.project.model.Attachment cannot be cast to com.company.project.model.Collision
请注意,绝对没有堆栈跟踪 - 至少不是我能够找到一个。我什至查看了服务器响应(AJAX),我们注意到一些异常有时会被吞没——什么都没有。
我发现了另外两个与我的问题相关的帖子(也未解决):
http://forum.primefaces.org/viewtopic.php?f=3&t=4270
http://forum.primefaces.org/viewtopic.php?f=3&t=5923
问:
有人知道 EL 表达式有什么问题#{not attachmentManager.markedToDelete(att)}
吗?
Q2: 堆栈跟踪可能会消失在哪里,或者更具体地说,我如何/在哪里找到它?
我们所处的环境是:GlassFish 3.1.2.2、Mojarra 2.1.6、PrimeFaces 3.4