开发者

Jsf dynamically created actionListener parameter

I have a custom facelet component (custom tag) but there is one thing that currently annoys me a lot. I'm trying to pass an action listener as a parameter to the custom tag, in order to make it more dynamic and just doesn't work.

Environment: JSF 1.2, IceFaces 1.8

Here's the way I'm trying to achieve this:

  • the command link开发者_Go百科 uses the passed parameter 'paginationController'

    <h:commandLink id="#{id}-link-three" value="click"
        actionListener="#{paginationController.paginationLinkClicked}" />
    
  • the parameter 'paginationController' is passed like this:

    paginationController="rowSelectController"
    
  • when I click the link, there's what I receive:

    Received 'javax.el.MethodNotFoundException' when invoking action listener
    '#{paginationController.paginationLinkClicked}' for component 'entity-list-apps-link-three'
    2011-02-22 12:49:47,803 SEVERE [javax.faces.event] (http-127.0.0.1-8080-4)
    javax.el.MethodNotFoundException: /WEB-INF/jsf/common/components/facelets
    /applicationList.xhtml @107,71 actionListener="#{paginationController.paginationLinkClicked}":
    Method not found: rowSelectController.paginationLinkClicked(javax.faces.event.ActionEvent)
    

So it seems that it successfully resolves the bean name to rowSelectController, but it complaints it can't find the method, and the method IS there!

One more thing, if I replace the parameter with the correct controller's name, it just works! Any ideas?


Because paginationController is variable you need to use the [] syntax here. Assuming paginationLinkClicked is a fixed method name:

<h:commandLink actionListener="#{paginationController['paginationLinkClicked']}" />

If paginationLinkClicked would also be variable, you need to omit the single quotes:

<h:commandLink actionListener="#{paginationController[paginationLinkClicked]}" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜