我遇到了这个问题:我有一个包含类型测试类对象列表的数据表,并且我有一个名为“分配给”的列,我想在其中显示该行中显示的测试分配给的用户的名称,所以我写了一个方法来做到这一点:
<p:column headerText="Assigned to">
<h:outputText value="#{projectCampaignManagementMB.initAssignedToData(test)}" />
</p:column>
我收到此错误:
nov. 04, 2012 4:42:06 PM com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback visit
Grave: javax.el.ELException: /campaingManagement.xhtml @2388,132 value="#{projectCampaignManagementMB.initAssignedToData(test)}": java.lang.NullPointerException
这是所有代码:
<p:dataTable var="test" value="#{projectCampaignManagementMB.campaignTestList}" >
<p:column headerText="User">
</p:column>
<p:column headerText="Assigned to">
<h:outputText value="#{projectCampaignManagementMB.initAssignedToData(test)}" />
</p:column>
</dataTable>
方法 :
public String initAssignedToData(Test pTest){
int assigendID = currentCampaign.getAssignedUserID(pTest);
User pUser = (User) userByID.get(new Integer(assigendID));
System.out.println("User assigned is = " + pUser + " , assigendID = " + assigendID);
return(((User) userByID.get(new Integer(assigendID))).getLoginFromModel()); // TO CHANGE
}
那么有没有另一种方法来实现这一点。非常感谢