Add s:jsCallbackFunction and s:jsOnEventAjax tags
-------------------------------------------------
Key: TOMAHAWK-1593
URL: https://issues.apache.org/jira/browse/TOMAHAWK-1593
Project: MyFaces Tomahawk
Issue Type: New Feature
Components: JSF2
Reporter: Leonardo Uribe
Assignee: Leonardo Uribe
Trying to do some stuff with JSF and javascript, I notice there is no tag that
can generate javascript functions inline.
This is different that a typical script block, when you put something that will
be executed as soon as the page is loaded. In this case, the function will be
used later by effect of a client behavior like f:ajax or s:effectXXX.
Usually as best practice, you put all javascript code in one place, but in
javascript it is common to use callbacks. For example, you want to execute some
javascript after an ajax operation. So you create a js function and then put
the function name on f:ajax onevent property, but you find quickly this does
not work with composite components that are used many times on the same page
because the script is rendered multiple times and the function is overriden
over and over. In cases like that you want an unique name based on a clientId,
so each time the component is rendered at different locations, a different name
is used.
s:jsCallbackFunction generate this content:
generatedFunctionNameUsingClientIdAndEventName = function (... arguments ...){
... jsStartContent ...
... clientBehavior scripts ...
... jsEndContent ...
}
and s:onEventAjax is similar to s:jsCallbackFunction, but specialized to
prevent write more javascript than necessary. It generated this content:
generatedFunctionNameUsingClientIdAndEventName = function (... arguments ...){
... jsStartContent ...
if(e.status == '...'){
... jsBeforeClientBehaviors ...
... clientBehavior scripts ...
... jsAfterClientBehaviors ...
}
... jsEndContent ...
}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira