1

I have two xhtml files, one includes another. I already know how to pass the controller and method to be called to the dialog, what I am not sure is possible, is to actually pass arguments/objects to the method that will be called. I tried something like this, but Eclipse tells me there is syntax error in this part

actionListener="#{bean[confMethod(param1, param2)]}"

but it does not have any problem with just

actionListener="#{bean[confMethod]}"

file1.xhtml:

<ui:composition>
.....
    <ui:include src="/jsf/include/dg_confirm.xhtml">
        <ui:param name="bean" value="#{myController}" />
        <ui:param name="question" value="Are you sure?" />
        <ui:param name="confMethod" value="myMethod" />
        <ui:param name="param1" value="#{otherController.param1}" />
        <ui:param name="param2" value="#{urlToFollow}" />
    </ui:include>

</ui:composition>

and the dialog

dg_confirm.xhtml

....
<p:commandButton value="Yes" oncomplete="PF('dlg_conf').hide();" actionListener="#{bean[confMethod(param1, param2)]}" ajax="false"/>
.....

Question: Is it possible to pass argument for the method somehow in JSF?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
hocikto
  • 871
  • 1
  • 14
  • 29
  • Start reading https://stackoverflow.com/questions/3284236/ and see if it helps to some extend (and eclipse is not always right) and posting version info when asking a question is always relevant! – Kukeltje Dec 18 '18 at 12:35

1 Answers1

5
actionListener="#{bean[confMethod(param1, param2)]}"

This syntax is indeed invalid. You're basically expecting that the confMethod is a static function which returns the name of the dynamic method based on the given two arguments.

The correct syntax is as below:

actionListener="#{bean[confMethod](param1, param2)}"
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Ohhh it was a real attempt, I thought it was pseudocode :-( Sorry – Kukeltje Dec 18 '18 at 17:50
  • @Kukeltje yes, those were the parameters that I passed from one XHTML file to another. Looks like pseudocode indeed. at BalusC took me a while to notice the difference, but it makes sense in the end. – hocikto Dec 18 '18 at 19:32