org.jsxp.framework
Class Context

java.lang.Object
  extended by org.jsxp.framework.Context

public class Context
extends java.lang.Object

The Class Context. Default implementation of a context. The context is automatically instantiated by the framework. You can access it with getContext(). Do not create an instance yourself.


Field Summary
protected static java.lang.String PREVIOUS_INPUT_PARAMETERS
          The Constant PREVIOUS_INPUT_PARAMETERS.
protected static java.lang.String RESTORE_PREVIOUS_INPUT
          The Constant RESTORE_PREVIOUS_INPUT.
 
Constructor Summary
protected Context()
          Instantiates a new context.
 
Method Summary
 void addDebugMessage(java.lang.String message)
          Adds the debug message.
 void addDeveloperWarningMessage(java.lang.String message)
          Adds a developer warning.
 void addFlashErrorMessage(java.lang.String message)
          Adds the flash message.
 void addFlashInformationMessage(java.lang.String message)
          Adds the flash message.
 void addFlashWarningMessage(java.lang.String message)
          Adds the flash message.
 void clearRedirect()
           
 java.lang.String getCommandId()
          Gets the command id if this is a command request
static
<T extends Context>
T
getContext()
          Gets the context.
 java.lang.String getContextPath()
          Gets the context path.
 java.util.Locale getCurrentLocale()
          Gets the current locale.
 java.util.List<java.lang.String> getDebugMessages()
          Gets the debug messages.
 java.lang.String getDelocalizedRequestUri()
           
 java.util.List<java.lang.String> getDeveloperWarnings()
          Gets the developer warnings.
 FlashMessages getFlashMessages()
          Gets the flash messages.
 javax.servlet.http.HttpServletRequest getHttpServletRequest()
          Gets the http servlet request.
 javax.servlet.http.HttpServletResponse getHttpServletResponse()
          Gets the http servlet response.
 javax.servlet.http.HttpSession getHttpSession()
          Gets the http session.
 ViewAlias getLastView()
          Gets the last view.
 java.lang.String getLocalizedRequestUri()
           
 ViewController getRedirectViewController()
          Gets the redirect view control if context was set for redirect.
 java.util.List<java.lang.String> getRemoveIds()
          Gets the removed IDs.
 java.util.Map<java.lang.String,java.lang.Object[]> getRequestInputParameter()
          Gets the request input parameter.
 java.util.Locale getRequestLocale()
          Gets the request locale.
 java.util.Map<java.lang.String,java.lang.Object[]> getSavedPreviousInput()
           
 Scopes<java.lang.String,java.lang.Object> getScopes()
          Gets the scopes.
 javax.servlet.Servlet getServlet()
          Gets the servlet.
 javax.servlet.ServletConfig getServletConfig()
          Gets the servlet config.
 javax.servlet.ServletContext getServletContext()
          Gets the servlet context.
 java.util.List<java.lang.String> getUpdateIds()
          Gets the update ids.
 UserContext getUserContext()
          Gets the current user context.
 boolean isCommandRequest()
           
 boolean isPartialRequest()
           
 boolean isPreviousInputSaved()
           
 boolean isRedirect()
           
 void redirect(java.lang.String url, boolean clientRedirect, java.util.Map<java.lang.String,java.lang.Object[]> redirectParameter)
          Marks the request for redirect to another url.
 void redirect(ViewAlias viewAlias, boolean clientRedirect)
          Marks the request for redirect to a view alias target.
 void redirect(ViewController redirectViewController, boolean clientRedirect, java.util.Map<java.lang.String,java.lang.Object[]> redirectParameter)
          Marks the request for redirect to another view.
 void saveInputToRestoreLater()
          Activate/deactivate the restoration of the previous input in the next request.
 void setDelocalizedRequestUri(java.lang.String delocalizedRequestUri)
           
 void setLocalizedRequestUri(java.lang.String localizedRequestUri)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREVIOUS_INPUT_PARAMETERS

protected static final java.lang.String PREVIOUS_INPUT_PARAMETERS
The Constant PREVIOUS_INPUT_PARAMETERS.

See Also:
Constant Field Values

RESTORE_PREVIOUS_INPUT

protected static final java.lang.String RESTORE_PREVIOUS_INPUT
The Constant RESTORE_PREVIOUS_INPUT.

See Also:
Constant Field Values
Constructor Detail

Context

protected Context()
Instantiates a new context. Should only be used by the jsxp framework. Use getContext() instead.

Method Detail

getContext

public static <T extends Context> T getContext()
Gets the context. Use this method to get the current context anywhere in your code.

Returns:
the context

addDebugMessage

public void addDebugMessage(java.lang.String message)
Adds the debug message.

Parameters:
message - the message
See Also:
DebugMessagesXhtmlController

addDeveloperWarningMessage

public void addDeveloperWarningMessage(java.lang.String message)
Adds a developer warning.

Parameters:
message - the message
See Also:
DeveloperWarningsXhtmlController

addFlashErrorMessage

public void addFlashErrorMessage(java.lang.String message)
Adds the flash message.

Parameters:
message - the message
See Also:
FlashMessagesXhtmlController

addFlashInformationMessage

public void addFlashInformationMessage(java.lang.String message)
Adds the flash message.

Parameters:
message - the message
See Also:
FlashMessagesXhtmlController

addFlashWarningMessage

public void addFlashWarningMessage(java.lang.String message)
Adds the flash message.

Parameters:
message - the message
See Also:
FlashMessagesXhtmlController

clearRedirect

public void clearRedirect()

getCommandId

public java.lang.String getCommandId()
Gets the command id if this is a command request

Returns:
a currently setted command if, if there is one in this request

getContextPath

public java.lang.String getContextPath()
Gets the context path.

Returns:
the context path

getCurrentLocale

public java.util.Locale getCurrentLocale()
Gets the current locale. Either it returns the locale that is explicitly set at the context via setRequestLocale(Locale) or it will try to find the best fitting locale regarding to the applications supported locales and the preferred locales from the user context. If nothing is found it will return the default application locale.

Returns:
the current locale

getDebugMessages

public java.util.List<java.lang.String> getDebugMessages()
Gets the debug messages.

Returns:
the debug messages
See Also:
DebugMessagesXhtmlController

getDelocalizedRequestUri

public java.lang.String getDelocalizedRequestUri()

getDeveloperWarnings

public java.util.List<java.lang.String> getDeveloperWarnings()
Gets the developer warnings.

Returns:
the developer warnings
See Also:
DeveloperWarningsXhtmlController

getFlashMessages

public FlashMessages getFlashMessages()
Gets the flash messages.

Returns:
the flash messages
See Also:
FlashMessagesXhtmlController, FlashMessages

getHttpServletRequest

public javax.servlet.http.HttpServletRequest getHttpServletRequest()
Gets the http servlet request.

Returns:
the http servlet request

getHttpServletResponse

public javax.servlet.http.HttpServletResponse getHttpServletResponse()
Gets the http servlet response.

Returns:
the http servlet response

getHttpSession

public javax.servlet.http.HttpSession getHttpSession()
Gets the http session.

Returns:
the http session

getLastView

public ViewAlias getLastView()
Gets the last view.

Returns:
the last view

getLocalizedRequestUri

public java.lang.String getLocalizedRequestUri()

getRedirectViewController

public final ViewController getRedirectViewController()
Gets the redirect view control if context was set for redirect.

Returns:
the redirect view control

getRemoveIds

public java.util.List<java.lang.String> getRemoveIds()
Gets the removed IDs. Used if the clients states that he wants to remove some elements from a view. E.g. used via AJAX in a WebApplication. You can call this method to know what elements the client want to get rid off.

Returns:
the removes the ids

getRequestInputParameter

public java.util.Map<java.lang.String,java.lang.Object[]> getRequestInputParameter()
Gets the request input parameter.

Returns:
the request input parameter

getRequestLocale

public java.util.Locale getRequestLocale()
Gets the request locale.

Returns:
the request locale

getSavedPreviousInput

public java.util.Map<java.lang.String,java.lang.Object[]> getSavedPreviousInput()
Returns:
the previous save input parameter

getScopes

public Scopes<java.lang.String,java.lang.Object> getScopes()
Gets the scopes.

Returns:
the scopes

getServlet

public javax.servlet.Servlet getServlet()
Gets the servlet.

Returns:
the servlet

getServletConfig

public javax.servlet.ServletConfig getServletConfig()
Gets the servlet config.

Returns:
the servlet config

getServletContext

public javax.servlet.ServletContext getServletContext()
Gets the servlet context.

Returns:
the servlet context

getUpdateIds

public java.util.List<java.lang.String> getUpdateIds()
Gets the update ids. Used if only special elements from a view are requested. E.g. used via AJAX in a WebApplication. You can call this method to know what elements are requested.

Returns:
the update ids

getUserContext

public UserContext getUserContext()
Gets the current user context.

Returns:
the user context

isCommandRequest

public boolean isCommandRequest()
Returns:
is this a command request (for example for AJAX)

isPartialRequest

public boolean isPartialRequest()
Returns:
is partial request

isPreviousInputSaved

public boolean isPreviousInputSaved()

isRedirect

public boolean isRedirect()
Returns:
true if the context is set for redirect and the redirect is a client side redirect, otherwise false

redirect

public final void redirect(java.lang.String url,
                           boolean clientRedirect,
                           java.util.Map<java.lang.String,java.lang.Object[]> redirectParameter)
Marks the request for redirect to another url.

Parameters:
url - the url
clientRedirect - true if the redirect is a client side redirect, otherwise it is a server side redirect
redirectParameter - the redirect parameter

redirect

public final void redirect(ViewAlias viewAlias,
                           boolean clientRedirect)
Marks the request for redirect to a view alias target.

Parameters:
viewAlias -
clientRedirect -

redirect

public final void redirect(ViewController redirectViewController,
                           boolean clientRedirect,
                           java.util.Map<java.lang.String,java.lang.Object[]> redirectParameter)
Marks the request for redirect to another view.

Parameters:
redirectViewController - the redirect view control
clientRedirect - true if the redirect is a client side redirect, otherwise it is a server side redirect
redirectParameter - the redirect parameter

saveInputToRestoreLater

public void saveInputToRestoreLater()
Activate/deactivate the restoration of the previous input in the next request. E.g. set this at the current context in a view controller to true, if you want to redirect to a html page in a web application and fill the form with the old values after a validation error.


setDelocalizedRequestUri

public void setDelocalizedRequestUri(java.lang.String delocalizedRequestUri)

setLocalizedRequestUri

public void setLocalizedRequestUri(java.lang.String localizedRequestUri)


Copyright © 2012 Oliver Szymanski & David Tanzer