Calling methods with EL parameters in JSF 1.2

I use datatable, and for each row I have two buttons: Change and Delete.

I need these buttons to be read-only, i.e. disabled if a certain condition is met for a given row. I saw in JSF 2 that you can pass parameters to method calls. Is there something equivalent in JSF 1.2?

Ideally, I would like something like (a cyclic variable is a loop, and there is another bean, an helper that contains a method that I would like to call):

<h:commandButton value="Edit" disabled="#{helper.isEditable(loop.id)}" /> 

In this case, the semantic meaning does not make sense to add the isEditable attribute to the bean, and it does not seem appropriate to create a wrapper around the bean.

Thanks in advance.

+6
el jsf
source share
1 answer

I saw in JSF 2 the ability to pass parameters to method calls. Is there something equivalent in JSF 1.2?

Passing parameters to non -JSF 2 specific method calls. It is specific to EL 2.2, which in turn is part of JSP 2.2 / Servlet 3.0 / Java EE 6. JSF 2 just happens to be part of Java EE 6. In other words, if you deploy your JSF 1.2 web application in a Servlet 3.0 compatible container such as Tomcat 7, Glassfish 3, etc., and your web.xml declared compatible with the version of the Servlet 3.0 specification, then it will simply generate a field for JSF 1 .x.

If you are still targeting the container of the old version of the servlet, you need to provide another EL implementation that supports method calls with arguments. One of these implementations is JBoss-EL , which you can install by simply dropping jboss-el.jar in /WEB-INF/lib your webapp and adding the following context parameter to web.xml . Here's an example specific to Mojarra ( Mojarra is codename JSF RI):

 <context-param> <param-name>com.sun.faces.expressionFactory</param-name> <param-value>org.jboss.el.ExpressionFactoryImpl</param-value> </context-param> 

If you use MyFaces as a JSF implementation, you need the following context parameter:

 <context-param> <param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name> <param-value>org.jboss.el.ExpressionFactoryImpl</param-value> </context-param> 

See also:

  • Call direct methods or methods with arguments / variables / parameters in EL
+8
source share

All Articles