o:methodParam
is a tag handler that can be used to pass a method expression
into a Facelets tag.
By default this is not possible, and the expression that's intended to be a method expression will be created and made available as a value expression. This handler should be placed inside a Facelets tag as follows:
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:o="http://omnifaces.org/ui" > <o:methodParam name="method" value="#{action}"/> <h:commandButton value="test" action="#{method}" /> </ui:composition>
Assuming the above is a tag called actionmethod
in the namespace test
, a method can be passed into it
as follows:
<test:actionmethod action="#{methodParamBean.doAction}" />
In case a method with no parameters is passed that is to be used as an action listener with no parameters, then the component
using this method unfortunely has to be wrapped by a component that puts the method in request scoped (with nested visibility),
e.g. by using ui:repeat
as follows:
<ui:repeat var="method" value="#{method}"> <h:commandButton value="test" actionListener="#{method}" /> </ui:repeat>
Using modern EL implementations, this is not needed in case the EL expression references the method using explicit parenthesis,
e.g. #{methodParamBean.doAction()}
Name | Required | Type | Description |
---|---|---|---|
name | true | javax.el.ValueExpression
(must evaluate to java.lang.String )
| Name under which the method expression will be made available to EL, scoped to the body of the Facelets tag. |
value | true | javax.el.ValueExpression
(must evaluate to java.lang.String )
| The value expression that is to be interpreted and invoked as a method expression. This is typically the name of the parameter by which a value is passed into the Facelets tag. |
Output generated by Vdldoc View Declaration Language Documentation Generator.