How to pass EL argument in method?

2019-02-27 22:36发布

I have just a question in passing parameters on backing beans method.

I would like pass an EL value between a method parameters like:

<p:selectOneMenu id="somsgroup" value="#{store_itemController.filter_sgroup}">
   <f:selectItems value="#{commonDataFunctions.getItemByName('store_sgroup', 'id', 'title', '[tb:store_sgroup][fd:title]=${store_itemController.filter_group}', '[tb:store_sgroup][fd:title]', true)}"/>
</p:selectOneMenu>

it seems like ${store_itemController.filter_group} it is not translated because the method receives ${store_itemController.filter_group} just like a string.

Is there a solution?

标签: jsf el
2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-02-27 23:19

I would like to suggest to use JBoss EL. If so, you need to configure as below in web.xml. Download jar file here and reference for previous post.

<context-param>     
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>   
</context-param>
查看更多
祖国的老花朵
3楼-- · 2019-02-27 23:31

You can indeed not nest EL expressions this way. EL expressions can only be inlined.

You can use <c:set> to create a new variable wherein the desired expression is inlined in the desired value and then reuse this variable as argument of another EL expression.

xmlns:c="http://java.sun.com/jsp/jstl/core"
...
<c:set var="filterGroup" value="[tb:store_sgroup][fd:title]=#{store_itemController.filter_group}" scope="request" />
...
<f:selectItems value="#{commonDataFunctions.getItemByName('store_sgroup', 'id', 'title', filterGroup, '[tb:store_sgroup][fd:title]', true)}"/>
查看更多
登录 后发表回答