Now, customerCaseController.customerCase.caseId is a string of numbers and is working if I just print it on the xhtml page as a heading or label.
I'd like to call the method findByCustomerCase(String caseId)
in my fileAttachmentController
but this isn't working:
<f:param customerCase="#{customerCaseController.customerCase.caseId}" />
<p:dataTable var="fileAttachment"
value="#{fileAttachmentController.findByCustomerCase(customerCase)}">
...table-contents...
</p:dataTable>
That would just pass the text "customerCase" as parameter to the method findByCustomerCase and not the value of the param customerCase. How can I pass the value?
Your problem is that you are using f:param
the wrong way. This element is not used to define a local variable. This means that customerCase
is not a valid variable at that point.
You are accessing customerCaseController.customerCase.caseId
and not just customerCase
, so you need to pass exactly the same as argument aswell and skip the whole f:param
.
Change your code to the following to get access to the desired caseId
:
<p:dataTable var="fileAttachment"
value="#{fileAttachmentController.findByCustomerCase(customerCaseController.customerCase.caseId)}">
...table-contents...
</p:dataTable>
In case you would like to keep the way of holding a local variable consider the following instead of f:param
:
<ui:param name="customerCase" value="#{customerCaseController.customerCase.caseId}" />
XML-Namespace: xmlns:ui="http://java.sun.com/jsf/facelets"
This will allow you to use your code from above. Just replace f:param
with this snippet.