¿Cómo pasar argumentos de método a un ActionListener?

I'm creating a dynamically generated menu. In the database, I have stored the directory (String) of each submenu and stored in an ArrayList in the bean. This is a part of the code:

<c:forEach items="#{controlWeb.algorithms}" var="alg">
    <h:form>
        <h:commandLink actionListener="#{controlWeb.setContent(PROBLEM)}"  value="About"/>
    </h:form>
</c:forEach>

The problem is in "PROBLEM". I want to write #{alg.algorithm1} and it doesn't work because I think it isn't posible to nest EL expressions.

El actionListener establecer el String #{alg.algorithm1} en otro String. How can I achieve the requirement?

preguntado el 31 de enero de 12 a las 16:01

1 Respuestas

Utilizan actionno, actionListener. El actionListener must be bound to a method which takes ActionEvent as the sole argument, no excuses. Also, an actionListener isn't intented to invocar actions, but to escuchamos on actions (so that you can log it or do some preprocessing task or whatever).

<c:forEach items="#{controlWeb.algorithms}" var="alg">
    <h:form>
        <h:commandLink action="#{controlWeb.setContent(alg.algorithm)}" value="About"/>
    </h:form>
</c:forEach>

Note that passing arguments in EL is only supported since EL 2.2 which is shipped along Servlet 3.0 / Java EE 6. You need to make sure that you're targeting a Servlet 3.0 compatible container with a Servlet 3.0 compatible web.xml.

Ver también:

Respondido el 20 de junio de 20 a las 12:06

Thank You so much again BalusC thanks to you im learning JSF so fastly. - Roberto

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.