2014-02-28 43 views
1

在我的facelet我有一個PF數據表,當我點擊一個頭排序,我得到 javax.el.ELException: Failed to parse the expression [#{item.null}]Primefaces的DataTable sortBy EL無法解析表達式

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()); 
} 

回答

1

<h:form>標籤圍繞數據表所需按工作排序。沒有它我得到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> 
0

刪除attempt1部分,它會完成。

由於PF 4,你不能有一個sortBy屬性當前對象,就在相關領域

sortBy="name" 

,而不是

sortBy="item.name" 
+0

//嘗試是不是真的在我的實際facelets頁面。我在這裏添加它來解釋我嘗試過(嘗試)「name」和「item.name」兩種方式都不起作用。 – jeff

+0

我不明白對不起。你可以嘗試使用'