在我的facelet中,当我点击标题进行排序时,我有一个PF数据表,我明白了
javax.el.ELException: Failed to parse the expression [#{item.null}]
ShippingRoom.xhtml
<f:metadata>
<o:viewParam name="id"
value="#{shippingRoomBean.room}"
converter="#{shippingRoomConverter}"
converterMessage="Unknown Shipping Room."
required="true"
requiredMessage="Bad request, please use a link from within the system." />
<f:event type="preRenderView" listener="#{shippingRoomBean.init}" />
</f:metadata>
Shipping Room Name: #{shippingRoomBean.name}<br/>
Shipping Room Location: #{shippingRoomBean.location}<br/>
<p:dataTable id="itemDataTable" var="item" value="#{shippingRoomBean.items}" emptyMessage="No Items Found In This Shipping Room">
<p:column sortBy="item.name" headerText="Item Name"> //attempt1
#{item.name}
</p:column>
<p:column sortBy="name" headerText="Item Name"> //attempt2
#{item.name}
</p:column>
ShippingRoomBean
@ManagedBean
@ViewScoped
public class ShippingRoomBean {
public void init() {
System.out.println("Initializing ==");
items = itemRepository.findItemsByShippingRoom(room.getId());
}
答案 0 :(得分:1)
数据表周围需要<h:form>
标记才能使sortBy正常工作。没有它,我得到javax.el.ELException: Failed to parse the expression [#{item.null}]
<h:form>
<p:dataTable id="itemDataTable" var="item" value="#{shippingRoomBean.items}" emptyMessage="No Items Found In This Shipping Room">
<p:column sortBy="name" headerText="Item Name">
#{item.name}
</p:column>
</p:dataTable>
</h:form>
答案 1 :(得分:0)
删除attempt1
部分,即可完成。
从PF 4开始,您不能在sortBy
属性中拥有当前对象,只能包含相关字段
sortBy="name"
而不是
sortBy="item.name"