org.omnifaces.context
Class OmniPartialViewContext

java.lang.Object
  extended by javax.faces.context.PartialViewContext
      extended by javax.faces.context.PartialViewContextWrapper
          extended by org.omnifaces.context.OmniPartialViewContext
All Implemented Interfaces:
javax.faces.FacesWrapper<javax.faces.context.PartialViewContext>

public class OmniPartialViewContext
extends javax.faces.context.PartialViewContextWrapper

This OmniFaces partial view context extends and improves the standard partial view context as follows:

You can use the Ajax utility class to easily add callback scripts and arguments.

This partial view context is already registered by OmniFaces' own faces-config.xml and thus gets auto-initialized when the OmniFaces JAR is bundled in a web application, so end-users do not need to register this partial view context explicitly themselves.

Since:
1.2
Author:
Bauke Scholtz

Field Summary
 
Fields inherited from class javax.faces.context.PartialViewContext
ALL_PARTIAL_PHASE_CLIENT_IDS, PARTIAL_EXECUTE_PARAM_NAME, PARTIAL_RENDER_PARAM_NAME
 
Constructor Summary
OmniPartialViewContext(javax.faces.context.PartialViewContext wrapped)
          Construct a new OmniFaces partial view context around the given wrapped partial view context.
 
Method Summary
 void addArgument(java.lang.String name, java.lang.Object value)
          Add an argument to the partial response.
 void addCallbackScript(java.lang.String callbackScript)
          Add a callback script to the partial response.
 void closePartialResponse()
          Close the partial response.
static OmniPartialViewContext getCurrentInstance()
          Returns the current instance of the OmniFaces partial view context.
 javax.faces.context.PartialResponseWriter getPartialResponseWriter()
           
 javax.faces.context.PartialViewContext getWrapped()
           
 void resetPartialResponse()
          Reset the partial response.
 void setPartialRequest(boolean isPartialRequest)
           
 
Methods inherited from class javax.faces.context.PartialViewContextWrapper
getExecuteIds, getRenderIds, isAjaxRequest, isExecuteAll, isPartialRequest, isRenderAll, processPartial, release, setRenderAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OmniPartialViewContext

public OmniPartialViewContext(javax.faces.context.PartialViewContext wrapped)
Construct a new OmniFaces partial view context around the given wrapped partial view context.

Parameters:
wrapped - The wrapped partial view context.
Method Detail

getPartialResponseWriter

public javax.faces.context.PartialResponseWriter getPartialResponseWriter()
Overrides:
getPartialResponseWriter in class javax.faces.context.PartialViewContextWrapper

setPartialRequest

public void setPartialRequest(boolean isPartialRequest)
Specified by:
setPartialRequest in class javax.faces.context.PartialViewContext

getWrapped

public javax.faces.context.PartialViewContext getWrapped()
Specified by:
getWrapped in interface javax.faces.FacesWrapper<javax.faces.context.PartialViewContext>
Overrides:
getWrapped in class javax.faces.context.PartialViewContextWrapper

addArgument

public void addArgument(java.lang.String name,
                        java.lang.Object value)
Add an argument to the partial response. This is as JSON object available by OmniFaces.Ajax.data. For supported argument value types, read Json.encode(Object). If a given argument type is not supported, then an IllegalArgumentException will be thrown during end of render response.

Parameters:
name - The argument name.
value - The argument value.

addCallbackScript

public void addCallbackScript(java.lang.String callbackScript)
Add a callback script to the partial response. This script will be executed once the partial response is successfully retrieved at the client side.

Parameters:
callbackScript - The callback script to be added to the partial response.

resetPartialResponse

public void resetPartialResponse()
Reset the partial response. This clears any JavaScript arguments and callbacks set any data written to the PartialResponseWriter.

See Also:
FullAjaxExceptionHandler

closePartialResponse

public void closePartialResponse()
Close the partial response. If the writer is still in update phase, then end the update and the document. This fixes the Mojarra problem of incomplete ajax responses caused by exceptions during ajax render response.

See Also:
FullAjaxExceptionHandler

getCurrentInstance

public static OmniPartialViewContext getCurrentInstance()
Returns the current instance of the OmniFaces partial view context.

Returns:
The current instance of the OmniFaces partial view context.
Throws:
java.lang.IllegalStateException - When there is no current instance of the OmniFaces partial view context. That can happen when the OmniPartialViewContextFactory is not properly registered, or when there's another PartialViewContext implementation which doesn't properly delegate through the wrapped instance.