我们有一个碰撞实体列表,您可以在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 -->
这是AttachmentManager
bean(@Named
和@Viewscoped
的类路径上的Seam 3 Faces兼容,在这里无关紧要):
@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
答案 0 :(得分:0)
我用2.1.14版交换了服务器的Mojarra,经过几次重载/重试后,堆栈跟踪终于出现了。 (在最初的几次尝试中,它们都是相同的,也许GlassFish缓存其JAR的相关部分)
之后它就像以前一样容易:我已经将等号方法从Collision
复制到Attachment
并将转换保持为Collision
不变。这就是导致CCE的原因。
然而,堆栈跟踪的发展仍然是一个谜......