How come JSF 2.x with EL 2.2 allows MethodExpression in place for ValueExpression?

萝らか妹 提交于 2019-12-07 22:18:53

问题


I am seeing several questions asking how to pass parameters to JSF methods. With EL2.2 and servlet 3.0, it enables user to pass parameters into a method call. One example: How to pass an argument to method from rendered h:outputText? The question is: In JSF 2.x, each tag attribute is supposed to take either ValueExpression or MethodExpression. In the linked example, "rendered" is supposed to only take ValueExpression. However I do see it still works with MethodExpression if we put () to make it clear it is a method call instead of a property. Is this something the JSF 2.x spec just messed up or am I missing something?


回答1:


Using the new EL 2.2 invoking-methods-with-arguments syntax in a value expression doesn't automagically make it a method expression or something. It's still a value expression. A value expression uses the returned value of the given EL expression as a value. A method expression invokes the given EL expression upon an action event associated with the component.

Whether the EL expression at its own invokes a property getter method or an arbitrary method with arguments really doesn't matter as to how the EL expression at the whole is treated.



来源:https://stackoverflow.com/questions/10201522/how-come-jsf-2-x-with-el-2-2-allows-methodexpression-in-place-for-valueexpressio

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