Dynamic Action in JSF page

半世苍凉 提交于 2019-12-04 09:08:11
BalusC

You can use the brace notation for that.

<h:commandButton value="submit" action="#{someBean[headerBean.actionValue]}" />

When the #{headerBean.actionValue} returns a String of for example doAction1, then this will effectively invoke #{someBean.doAction1}.

If the bean name to be called is currently actually in the actionvalue (headerBean.actionValue returning someBean.doAction1), you need to split it into a field that returns the bean name and one that returns the method name and then use

<h:commandButton value="submit" action="#{requestScope[headerBean.beanName][headerBean.actionValue]}" />

If headerBean.beanName returns 'someBean' and headerBean.actionValue returns doAction1 the above will call #{somebean.doAction1}.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!