Steve Waters Steve Waters - 1 year ago 69
Java Question

How to pass JSF param's value as method parameter?

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
but this isn't working:

<f:param customerCase="#{customerCaseController.customerCase.caseId}" />
<p:dataTable var="fileAttachment"



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?

Answer Source

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.caseIdand 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" 



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=""

This will allow you to use your code from above. Just replace f:param with this snippet.