1

现在,customerCaseController.customerCase.caseId 是一串数字,如果我只是将它作为标题或标签打印在 xhtml 页面上,它就可以工作。

我想findByCustomerCase(String caseId)在我的方法中调用该方法,fileAttachmentController但这不起作用:

   <f:param customerCase="#{customerCaseController.customerCase.caseId}" />
    <p:dataTable var="fileAttachment" 
    value="#{fileAttachmentController.findByCustomerCase(customerCase)}">

   ...table-contents...

   </p:dataTable>

这只会将文本“customerCase”作为参数传递给方法 findByCustomerCase,而不是参数 customerCase 的值。我怎样才能传递价值?

4

1 回答 1

2

你的问题是你使用f:param了错误的方法。此元素不用于定义局部变量。这意味着那customerCase不是一个有效的变量。

您正在访问customerCaseController.customerCase.caseId而不仅仅是访问customerCase,因此您还需要传递与参数完全相同的内容并跳过整个内容f:param

将您的代码更改为以下内容以访问所需的caseId

<p:dataTable var="fileAttachment" 
 value="#{fileAttachmentController.findByCustomerCase(customerCaseController.customerCase.caseId)}">

...table-contents...

</p:dataTable>

如果您想保留保存局部变量的方式,请考虑以下内容而不是f:param

<ui:param name="customerCase" value="#{customerCaseController.customerCase.caseId}" />

XML 命名空间:xmlns:ui="http://java.sun.com/jsf/facelets"

这将允许您使用上面的代码。只需替换f:param此代码段即可。

于 2016-05-06T12:40:03.313 回答