common-util

local.tomas.faces
Class FacesSession

java.lang.Object
  extended by local.tomas.faces.FacesSession

public abstract class FacesSession
extends Object

Abstract base class for JSF session.

Author:
tomas

Constructor Summary
protected FacesSession()
          Default constructor.
 
Method Summary
 void addLocalizedMessage(String key)
          Add localized message to current faces context instance.
 void addLocalizedMessage(String id, String key)
          Add localized message to current faces context instance.
 void addLocalizedMessage(String id, String key, Object arg)
          Add localized messsage with one argument to current faces context instance.
 void addLocalizedMessage(String id, String key, Object[] args)
          Add localized messsage with arguments to current faces context instance.
 void addLocalizedMessage(String id, String key, Object arg1, Object arg2)
          Add localized messsage with two arguments to current faces context instance.
 void addMessage(javax.faces.context.FacesContext context, String id, String message)
          Add message to faces context.
 void addNativeMessage(String message)
          Add message to current faces context instance.
 void addNativeMessage(String id, String message)
          Add message to current faces context instance.
protected  Locale determineLocale(javax.faces.context.FacesContext context)
          Try to determine locale from FacesContext.
 Locale getDefaultLocale()
          Try to determine locale from current FacesContext instance.
 Locale getLocale()
          Get locale of current FacesContext instance.
 String getLocalizedMessage(javax.faces.context.FacesContext context, Locale locale, String key)
          Get localized message from application bundle.
 String getLocalizedMessage(javax.faces.context.FacesContext context, String key)
          Get localized message from application bundle.
static FacesSession getSession(String name)
          Get named faces session.
static Object resolveVariable(String name)
          Resolve JSF variable by name.
 void setLocale(Locale locale)
          Set locale.
 void setRequestAttribute(String name, Object value)
          Set request attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FacesSession

protected FacesSession()
Default constructor.

Method Detail

determineLocale

protected Locale determineLocale(javax.faces.context.FacesContext context)
Try to determine locale from FacesContext. The locale of the view root is returned if it is not null. Otherwise the request locale of the external context is returned. The locale determined is cached in the session instance and returned by subsequent invocations.

Parameters:
context - the context
Returns:
The locale

getDefaultLocale

public Locale getDefaultLocale()
Try to determine locale from current FacesContext instance. The locale of the view root is returned if it is not null. Otherwise the request locale of the external context is returned. The locale determined is cached in the session instance and returned by subsequent invocations. The default locale is returned if a runtime exception occurs.

Returns:
The locale

getLocale

public Locale getLocale()
Get locale of current FacesContext instance. The request locale of the external context is returned if there is no current FacesContext instance. The locale determined is cached in the session instance and returned by subsequent invocations.

Returns:
The locale

setLocale

public void setLocale(Locale locale)
Set locale. Explicitly set the cached locale.

Parameters:
locale - The locale

addMessage

public void addMessage(javax.faces.context.FacesContext context,
                       String id,
                       String message)
Add message to faces context.

Parameters:
context - faces context
id - the message id
message - the message text

addNativeMessage

public void addNativeMessage(String id,
                             String message)
Add message to current faces context instance.

Parameters:
id - the message id
message - the message text

addNativeMessage

public void addNativeMessage(String message)
Add message to current faces context instance.

Parameters:
message - the message text

getLocalizedMessage

public String getLocalizedMessage(javax.faces.context.FacesContext context,
                                  Locale locale,
                                  String key)
Get localized message from application bundle.

Parameters:
context - faces context
locale - locale used to retrieve message
key - message key
Returns:
the message text

getLocalizedMessage

public String getLocalizedMessage(javax.faces.context.FacesContext context,
                                  String key)
Get localized message from application bundle.

Parameters:
context - faces context
key - message key
Returns:
the message text

addLocalizedMessage

public void addLocalizedMessage(String id,
                                String key)
Add localized message to current faces context instance.

Parameters:
id - message id
key - message key

addLocalizedMessage

public void addLocalizedMessage(String key)
Add localized message to current faces context instance.

Parameters:
key - message key

addLocalizedMessage

public void addLocalizedMessage(String id,
                                String key,
                                Object[] args)
Add localized messsage with arguments to current faces context instance.

Parameters:
id - message id
key - message key
args - message arguments

addLocalizedMessage

public void addLocalizedMessage(String id,
                                String key,
                                Object arg)
Add localized messsage with one argument to current faces context instance.

Parameters:
id - message id
key - message key
arg - argument

addLocalizedMessage

public void addLocalizedMessage(String id,
                                String key,
                                Object arg1,
                                Object arg2)
Add localized messsage with two arguments to current faces context instance.

Parameters:
id - message id
key - message key
arg1 - argument 1
arg2 - argument 2

resolveVariable

public static Object resolveVariable(String name)
Resolve JSF variable by name.

Parameters:
name - variable name
Returns:
variable value

getSession

public static FacesSession getSession(String name)
Get named faces session.

Parameters:
name - session name
Returns:
the session

setRequestAttribute

public void setRequestAttribute(String name,
                                Object value)
Set request attribute.

Parameters:
name - attribute name
value - attribute value

common-util

Copyright © 2007 null. All Rights Reserved.