• Post Reply Bookmark Topic Watch Topic
  • New Topic

What does mojarra.ab(this,event,'action',0,0);return false mean ?  RSS feed

 
Cedric Bosch
Ranch Hand
Posts: 99
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems like the onclick generated by the f:ajax attribute is often the same. I would like to understand what are the parameters and what they represent.



Also is it safe to assume it is gonna be generated exactly like that every time when it's a simple commandButton with an empty tag in it ?

I get that the return false is to prevent the default behavior of on click. But I'm not sure about the rest nor do I know where to check the source for majorra.

Also I noticed a function appearing sometime, along:



It might not be exactly that
That one is just to execute a x number of function consecutively (or short circuit it if any of the fct returns false) and nothing else ? I'd like to check its content as well.

The doc says:

A varargs function that invokes an arbitrary number of scripts. If any script in the chain returns false, the chain is short-circuited and subsequent scripts are not invoked. Any number of scripts may specified after the event argument.
 
Cedric Bosch
Ranch Hand
Posts: 99
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
found this :
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I'm not sure what you are doing there. It looks like you are wandering around inside JSF internal code. None of the google searches on "mojarra.ab" resulting in any JSF function formally blessed (documented) by Oracle, and mojarra is a specific JSF implementation, so using anything labelled "mojarra" is likely to break in the future. For that matter, the "jsf.util.chain" example didn't make sense to me either.

When you code an f:ajax tag and specify a listener attribure, then when the event you've indicated fires, an AJAX submit of the form (or at least designated parts of it) are sent to the server where the normal JSF lifecycle (mostly) applies. Because the submit included a listener, JSF will look for the listener's server-side method in the backing bean and invoke it. The single parameter is an object of type javax.faces.event.AjaxBehaviorEvent, and that object contains a reference to the UIComponent that the AJAX tag is attached to.

If you didn't specify a listener event, then standard JSF lifecycle processing rules mandate that whatever form controls are indicated by the ajax tag (by default, just its parent) will be validated and the backing bean will be updated. If validation fails, of course, updating does not occur. If a listener was specified, the backing bean will have had its data properties updated before the listener is invoked. Which means in most cases, you can ignore the listener parameter altogether, since meddling directly with UI components should be avoided where possible.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!