org.omnifaces.util
Class Ajax

java.lang.Object
  extended by org.omnifaces.util.Ajax

public final class Ajax
extends java.lang.Object

Collection of utility methods for working with PartialViewContext. There are also shortcuts to the current OmniPartialViewContext instance.

Since:
1.2
Author:
Bauke Scholtz

Method Summary
static void data(java.util.Map<java.lang.String,java.lang.Object> data)
          Add the given mapping of data arguments to the current ajax response.
static void data(java.lang.Object... namesValues)
          Add the given data arguments to the current ajax response.
static void data(java.lang.String name, java.lang.Object value)
          Add the given data argument to the current ajax response.
static javax.faces.context.PartialViewContext getContext()
          Returns the current partial view context (the ajax context).
static void oncomplete(java.lang.String... scripts)
          Execute the given scripts on complete of the current ajax response.
static void update(java.lang.String... clientIds)
          Update the given client IDs in the current ajax response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getContext

public static javax.faces.context.PartialViewContext getContext()
Returns the current partial view context (the ajax context).

Note that whenever you absolutely need this method to perform a general task, you might want to consider to submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general task.

Returns:
The current partial view context.
See Also:
FacesContext.getPartialViewContext()

update

public static void update(java.lang.String... clientIds)
Update the given client IDs in the current ajax response. Note that those client IDs should not start with the naming container separator character like :.

Parameters:
clientIds - The client IDs to be updated in the current ajax response.
See Also:
PartialViewContext.getRenderIds()

oncomplete

public static void oncomplete(java.lang.String... scripts)
Execute the given scripts on complete of the current ajax response.

Parameters:
scripts - The scripts to be executed.
See Also:
OmniPartialViewContext.addCallbackScript(String)

data

public static void data(java.lang.String name,
                        java.lang.Object value)
Add the given data argument to the current ajax response. They are as JSON object available by OmniFaces.Ajax.data.

Parameters:
name - The argument name.
value - The argument value.
See Also:
OmniPartialViewContext.addArgument(String, Object)

data

public static void data(java.lang.Object... namesValues)
Add the given data arguments to the current ajax response. The arguments length must be even. Every first and second argument is considered the name and value pair. The name must always be a String. They are as JSON object available by OmniFaces.Ajax.data.

Parameters:
namesValues - The argument names and values.
Throws:
java.lang.IllegalArgumentException - When the arguments length is not even, or when a name is not a string.
See Also:
OmniPartialViewContext.addArgument(String, Object)

data

public static void data(java.util.Map<java.lang.String,java.lang.Object> data)
Add the given mapping of data arguments to the current ajax response. They are as JSON object available by OmniFaces.Ajax.data.

Parameters:
data - The mapping of data arguments.
See Also:
OmniPartialViewContext.addArgument(String, Object)