6 Replies Latest reply on Jun 7, 2013 6:48 PM by Brian Leathem

    a4j:ajax support for action calls with an argument

    Sean Tozer Newbie

      Hi all,


      We're currently deep into a RF3-->RF4 migration. It's been a lot of work, since it's a fairly big project, but I wouldn't say it's gone un-smoothly so far, at least from a RichFaces perspective. However, we've now run into an issue which I can't seem to find a clean workaround for. It seems like it should be a relatively simple thing to migrate:


      {code}<a4j:support action="#{backingBean.save(item)}"/>{code}


      That is, an ajax support call to an action method which takes a parameter. There are many other examples of methods and arguments, but that's a reasonably representative case.


      Without a parameter, we can do


      {code}<a4j:ajax listener="#{backingBean.save}" />{code}


      which works, although it seems kind of hackish to be treating an action method as a listener. It's really an action that just happens to be taking advantage of the fact that listener methods don't require that you accept the ActionEvent argument. It works, but it doesn't seem right. However, I can live with that.


      For methods that need a parameter, though, there doesn't seem to be any reasonable workaround for passing that argument. I've seen some mentions of using an a4j:jsFunction, but that's even more hackish, hard to maintain, and doesn't really work very cleanly over iteration. I've just had a quick look at PrimeFaces, which seems to have the same issue. That leads me to believe that it's some problem with the underlying JSF spec. That would be fine, except that RF3 had that functionality, which makes it a big issue for migrations. Is there any hope of a4j:ajax supporting a proper action method in the near future? If not, is there any workaround, or should we instead be thinking about refactoring (potentially dramatically, in some cases) to try to avoid needing parameters?


      Thanks in advance!