1

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?

1 Answer 1

2

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

1
  • Thanks! That works. I guess I'm just not used to the xhtml side of things yet. +1 for bringing up the ui:param. May 6, 2016 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.