o

Tag
commandScript

Description:

CommandScript is an extension to <h:commandXxx> which generates a JavaScript
function in the global JavaScript scope which allows the enduser to execute a JSF ajax request by a just function
call functionName() in the JavaScript context.

The <o:commandScript> component is required to be enclosed in an UIForm component. The
name attribute is required and it represents the JavaScript function name. The execute
and render attributes work exactly the same as in <f:ajax>. The onbegin
and oncomplete attributes must represent (valid!) JavaScript code which will be executed before sending
the ajax request and after processing the ajax response respectively. The action,
actionListener and immediate attributes work exactly the same as in
<h:commandXxx>.

Basic usage example of <o:commandScript> which submits the entire form on click of a plain HTML
button:

The component also supports nesting of <f:param>, <f:actionListener> and
<f:setPropertyActionListener>, exactly like as in <h:commandXxx>. The function
also supports a JS object as argument which will then end up in the HTTP request parameter map:

functionName({ name1: "value1", name2: "value2" });

With the above example, the parameters are in the action method available as follows:

Whether the command script should automatically run inline during page load.
Note that this thus runs immediately at the moment the script is been interpreted by the web browser
and thus not in end of HTML body or during window load event. So if the script logic depends on the
HTML DOM tree composition, then it will depend on location of the command script component itself.

MethodExpression representing the application action to invoke when this component is
activated by the user. The expression must evaluate to a public method that takes no parameters, and
returns an Object (the toString() of which is called to derive the logical
outcome) which is passed to the NavigationHandler for this application.

MethodExpression representing an action listener method that will be notified when this
component is activated by the user. The expression must evaluate to a public method that takes an
ActionEvent parameter, with a return type of void, or to a public method that takes no
arguments with a return type of void. In the latter case, the method has no way of easily knowing
where the event came from, but this can be useful in cases where a notification is needed that
"some action happened".

Flag indicating that, if this component is activated by the user, notifications should be delivered
to interested listeners and actions immediately (that is, during Apply Request Values phase) rather
than waiting until Invoke Application phase.