1

我使用的是 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 方法 -> 从上面的操作调用传递的参数解析为托管 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 子表中没有正确传递参数?我在没有子表的数据表中尝试了它,它工作正常。请帮助,非常感谢您的帮助。

4

1 回答 1

0

那么你所做的是好的,它应该可以工作,我做了一个测试并且参数是从p:subtable. 也许你的p:dataTable建筑有问题?

于 2012-07-24T09:25:13.677 回答