JSF2 Action parameter

前端 未结 3 1834
名媛妹妹
名媛妹妹 2020-12-03 02:03

I have read about passing parameters from jsf page to managedbean through actionListener. Is it also possible to pass a parameter to a simple action method?

Thank y

3条回答
  •  情书的邮戳
    2020-12-03 02:34

    You're talking about parameters in this form?

    
    

    That depends on the EL implementation. Only JBoss EL and JSP 2.2 EL is capable of doing this. How to install JBoss EL is described in this answer.

    Alternatively, you can also just use f:param. The f:param used to work with h:commandLink only, but since JSF 2.0 it also works on h:commandButton. E.g.

    
        
    
    

    with a @ManagedProperty which sets the parameter as managed bean property:

    @ManagedProperty("#{param.foo}")
    private String foo;
    

    With this you're however limited to standard types (String, Number, Boolean). An alternative is the f:setPropertyActionListener:

    
        
    
    

    That said, there are more ways as well, but this all depends on the sole functional requirement and the bean scopes. Probably you don't need to pass a "parameter" at all after all.

提交回复
热议问题