Avoid separate function for commandLink action
I would like to use a property of a form element instead of using an additional function to just return a certain value.
Current situation
XHTML file:
<h:commandLink action="#{menuBean.navigationAction(menuItem)}" ... >
Managed Bean behind it:
public function navigationAction(MenuItem entry) {
return entry.getForward();
}
Desired situation
I would like to skip the method call and directly use the property of menuItem
to set the destination. Like this:
<h:commandLink action="#{menuItem.forward}" />
This does unfortunately not work, as the method cannot be 开发者_运维知识库found. Is it even possible to do so?
You could try this:
<h:link outcome="#{menuItem.forward}" .../>
The outcome
parameter takes a value expression that must resolve to a string. The action
attribute of h:commandLink
needs a method expression.
精彩评论