org.primefaces.context
Class RequestContext

java.lang.Object
  extended by org.primefaces.context.RequestContext
Direct Known Subclasses:
DefaultRequestContext

public abstract class RequestContext
extends Object

A RequestContext is a helper class consisting of several utilities. RequestContext is thread-safe and scope is same as FacesContext. Current instance can be retrieved as;

RequestContext.getCurrentInstance();


Constructor Summary
RequestContext()
           
 
Method Summary
abstract  void addCallbackParam(String name, Object value)
          Add a parameter for ajax oncomplete client side callbacks.
abstract  void closeDialog(Object data)
          Close a dialog.
abstract  void execute(String script)
          Execute a javascript after current ajax request is completed.
abstract  AjaxRequestBuilder getAjaxRequestBuilder()
           
abstract  ApplicationContext getApplicationContext()
           
abstract  Map<Object,Object> getAttributes()
           
abstract  Map<String,Object> getCallbackParams()
           
abstract  CSVBuilder getCSVBuilder()
           
static RequestContext getCurrentInstance()
           
abstract  StringEncrypter getEncrypter()
           
abstract  List<String> getScriptsToExecute()
           
abstract  WidgetBuilder getWidgetBuilder()
           
abstract  boolean isAjaxRequest()
           
abstract  boolean isIgnoreAutoUpdate()
           
abstract  boolean isSecure()
          Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
abstract  void openDialog(String outcome)
          Open a view in dialog.
abstract  void openDialog(String outcome, Map<String,Object> options, Map<String,List<String>> params)
          Open a view in dialog.
abstract  void release()
          Clear resources.
abstract  void reset(Collection<String> expressions)
          Reset a collection of editableValueHolders.
abstract  void reset(String expressions)
          Reset an editableValueHolder.
abstract  void scrollTo(String clientId)
          Scroll to a component after ajax request is completed.
static void setCurrentInstance(RequestContext context)
           
abstract  void showMessageInDialog(javax.faces.application.FacesMessage message)
          Displays a message in a dialog.
abstract  void update(Collection<String> collection)
          Update components with ajax.
abstract  void update(String name)
          Update a component with ajax.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestContext

public RequestContext()
Method Detail

getCurrentInstance

public static RequestContext getCurrentInstance()

setCurrentInstance

public static void setCurrentInstance(RequestContext context)

isAjaxRequest

public abstract boolean isAjaxRequest()
Returns:
true if request is an ajax request, otherwise return false.

addCallbackParam

public abstract void addCallbackParam(String name,
                                      Object value)
Add a parameter for ajax oncomplete client side callbacks. Value would be serialized to json.

Parameters:
name - name of the parameter.
object - value of the parameter.

getCallbackParams

public abstract Map<String,Object> getCallbackParams()
Returns:
all callback parameters added in the current request.

getScriptsToExecute

public abstract List<String> getScriptsToExecute()
Returns:
all scripts added in the current request.

execute

public abstract void execute(String script)
Execute a javascript after current ajax request is completed.

Parameters:
script - Javascript statement to execute.

scrollTo

public abstract void scrollTo(String clientId)
Scroll to a component after ajax request is completed.

Parameters:
clientId - Client side identifier of the component.

update

public abstract void update(String name)
Update a component with ajax.

Parameters:
name - Client side identifier of the component.

update

public abstract void update(Collection<String> collection)
Update components with ajax.

Parameters:
collection - Client side identifiers of the components.

reset

public abstract void reset(String expressions)
Reset an editableValueHolder.

Parameters:
expressions - A string with one or multiple search expression to resolve the components.

reset

public abstract void reset(Collection<String> expressions)
Reset a collection of editableValueHolders.

Parameters:
expressions - A list with with one or multiple search expression to resolve the components.

getWidgetBuilder

public abstract WidgetBuilder getWidgetBuilder()
Returns:
Shared WidgetBuilder instance of the current request

getAjaxRequestBuilder

public abstract AjaxRequestBuilder getAjaxRequestBuilder()
Returns:
Shared AjaxRequestBuilder instance of the current request

getCSVBuilder

public abstract CSVBuilder getCSVBuilder()
Returns:
Shared Client Side Validation builder instance of the current request

getAttributes

public abstract Map<Object,Object> getAttributes()
Returns:
Attributes map in RequestContext scope

openDialog

public abstract void openDialog(String outcome)
Open a view in dialog.

Parameters:
outcome - The logical outcome used to resolve a navigation case.

openDialog

public abstract void openDialog(String outcome,
                                Map<String,Object> options,
                                Map<String,List<String>> params)
Open a view in dialog.

Parameters:
outcome - The logical outcome used to resolve a navigation case.
options - Configuration options for the dialog.
params - Parameters to send to the view displayed in a dialog.

closeDialog

public abstract void closeDialog(Object data)
Close a dialog.

Parameters:
data - Optional data to pass back to a dialogReturn event.

showMessageInDialog

public abstract void showMessageInDialog(javax.faces.application.FacesMessage message)
Displays a message in a dialog.

Parameters:
message - FacesMessage to be displayed.

getApplicationContext

public abstract ApplicationContext getApplicationContext()
Returns:
ApplicationContext instance.

getEncrypter

public abstract StringEncrypter getEncrypter()
Returns:
StringEncrypter used to encode and decode a string.

release

public abstract void release()
Clear resources.


isSecure

public abstract boolean isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.


isIgnoreAutoUpdate

public abstract boolean isIgnoreAutoUpdate()
Returns:
true if AutoUpdatable components should not be updated automatically in this request.


Copyright © 2013. All rights reserved.