我使用的是primefaces 3.3.1,mojarra 2.1.3,netbeans 7.0.1。
<p:dataTable id="approvalchainstable" var="department" value="#{viewApprovalChain.wfdepartments}">
<p:columnGroup type="header">
<p:row>
<p:column colspan="4" headerText="#{bundle.DepartmentNameFieldLabel}" />
</p:row>
<p:row>
<p:column headerText="#{bundle.PostNameFieldLabel}"/>
<p:column headerText="#{bundle.ItemCountLabel} #{bundle.ApprovalLevelNameFieldLabel}"/>
<p:column headerText="#{bundle.ViewLabel}"/>
<p:column headerText="#{bundle.LabelDelete}"/>
</p:row>
</p:columnGroup>
<p:subTable var="approvalchain" value="#{department.wfApprovalchainCollection}">
<f:facet name="header">
#{department.wfDepartmentName}
</f:facet>
<p:column>
#{approvalchain.idWfPost.wfPostName}
</p:column>
<p:column>
#{approvalchain.wfApprovalchainLevel}
</p:column>
<p:column>
<h:link outcome="/viewApprovalChainDetails" value="#{bundle.ViewLabel}">
<f:param name="idWfApprovalChain" value="#{approvalchain.idWfApprovalchain}"/>
</h:link>
</p:column>
<p:column>
<p:commandButton value="#{bundle.LabelDelete}"
title="Delete"
icon="ui-icon-trash"
action="#{viewApprovalChain.removeOneApprovalchain(approvalchain)}">
</p:commandButton>
</p:column>
</p:subTable>
</p:dataTable>
这里是ViewScoped托管bean方法 - &gt;从上面的动作调用传递的参数在托管bean中解析为null。因此我收到了NullPointerException错误。
public String removeOneApprovalchain(WfApprovalchain wfapprovalchaintoremove) {
try {
LogController.log.info("Removing approval chain flow for application " +
wfapprovalchaintoremove.getIdWfApplication().getWfApplicationName() +
" applicable for " + wfapprovalchaintoremove.getIdWfPost().getWfPostName() +
" in " + wfapprovalchaintoremove.getIdWfDepartment().getWfDepartmentName());
wfApprovalchainFacade.remove(wfapprovalchaintoremove);
LogController.log.info("Reloading department names for the select one box");
wfdepartments = wfDepartmentFacade.selectAll();
} catch (Exception ex) {
LogController.log.fatal(ex.toString());
} finally {
return null;
}
}
我很自信我做得对。但是为什么wfapprovalchaintoremove对象参数总是解析为null?为什么参数未在primefaces子表中正确传递?我尝试了没有子表的数据表内部,它正常工作。请帮助,非常感谢您的帮助。
答案 0 :(得分:0)
你做的是好的,它应该工作,我做了一个测试,参数从p:subtable
正确传递。也许你的p:dataTable
建筑有问题吗?