1

This is my first question here and on top of that I'm really, really new to Spring/JSF/RichFaces (about 3 weeks) so, I'm sorry if my question is dumb :)

Long story short, having the following:

  • a4j:commandLink
  • action="myBean.doSomething" method that (among other things) updates a JSON parameter and returns another navigation page (so clicking on the commandLink moves the user on another page)
  • in the above case the oncomplete event does not trigger.

What I need to do is to refresh the JSON parameter so I can use it in a JS function before the user is moved to the next page. Since oncomplete doesn't trigger in my case I had to find a way around it but I am really not sure how "bullet proof" is the way I implemented. (not to mention that it is quite troublesome to implement it all over the place)

What I did so far was to have the commandLink's action point to the bean's method that does everything except returning the new navigation page and on oncomplete event to run my JS function with the updated JSON object then call a previously declared jsFunction that all it does is to return the navigation page.

It works ok, I guess, but I was wondering if there's "an official" (proper) way to do it (like forcing the oncomplete or similar event that comes after the action where I can use javascript).

Here's the example:

<a4j:form id="myForm">      
      <a4j:jsFunction name="moveToNextPage" action="next_page"/>
      <a4j:commandLink action="#{myBean.doLogicAndUpdateJSON}"
            oncomplete="callJSfunction(#{myBean.objJSON});moveToNextPage();">
      </a4j:commandLink>
</a4j:form>

Thanks!

DaniL
  • 23
  • 6
  • Try adding `return false;` to the end of the oncomplete business – kolossus Jan 30 '15 at 00:34
  • @kolossus - You mean in the code example I posted? That code works just fine, but I see it as kind of a hack. What I need is to find a way to get rid of the jsFunction `moveToNextPage` and insert the navigation case into the `myBean.doLogicAndUpdateJSON`. But before the user gets moved to the next page, I need to call a javascript function (`callJSfunction(#{myBean.objJSON});`) with an updated value of `myBean.objJSON`. – DaniL Jan 30 '15 at 09:43

0 Answers0