开发者

Avoid separate function for commandLink action

开发者 https://www.devze.com 2023-04-09 10:45 出处:网络
I would like to use a property of a form element instead of using an additional function to just return a certain value.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号