How to pass EL argument in method?

*爱你&永不变心* 提交于 2019-12-04 05:02:11

问题


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?


回答1:


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)}"/>



回答2:


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>


来源:https://stackoverflow.com/questions/13009004/how-to-pass-el-argument-in-method

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