I have a page which includes content from another page dynamically (this is done by a method in the bean)
firstPage.xhtml
<ui:include src="#{managedBean.pageView}">
<ui:param name="method" value="#{managedBean.someAction}"/>
</ui:include>
This redirects to a secondPage which is within <ui:composition>
which has commandButton.
secondPage.xhtml
<ui:composition>
..
..
<p:commandButton actionListener=#{method} value="Submit"/>
</ui:composition>
ManagedBean
public String pageView(){
return "secondPage.xhtml";
}
public void someAction(){
*someAction*
}
The commandButton in the secondPage.xhtml is not working.
Any help shall be much appreciated.
You can't pass method expressions via
<ui:param>
. They're interpreted as value expression.You've basically 3 options:
Split the bean instance and the method name over 2 parameters:
And couple them in the tag file using brace notation
[]
as follows:Create a tag handler which converts a value expression to a method expression. The JSF utility library OmniFaces has a
<o:methodParam>
which does that. Use it as follows in the tag file:Use a composite component instead. You can use
<cc:attribute method-signature>
to define action methods as attributes.Which is used as follows: