org.apache.struts.webapp.example
Class LocaleAction

java.lang.Object
  extended byorg.apache.struts.action.Action
      extended byorg.apache.struts.webapp.example.BaseAction
          extended byorg.apache.struts.webapp.example.LocaleAction

public final class LocaleAction
extends BaseAction

Change user's Struts @link(java.util.Locale).


Field Summary
private static String COUNTRY
          Parameter for @link(java.util.Locale) country property.
private static String FORWARD
          Parameter for response forward name.
private static String LANGUAGE
          Parameter for @link(java.util.Locale) language property.
private static String LOCALE_LOG
          Logging message if LocaleAction is missing a target parameter.
private static String PAGE
          Parameter for response page URI.
 
Fields inherited from class org.apache.struts.webapp.example.BaseAction
log
 
Fields inherited from class org.apache.struts.action.Action
defaultLocale, servlet
 
Constructor Summary
LocaleAction()
           
 
Method Summary
 org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           Change the user's Struts @link(java.util.Locale) based on request parameters for "language", "country".
private  boolean isBlank(String string)
          Return true if parameter is null or trims to empty.
 
Methods inherited from class org.apache.struts.webapp.example.BaseAction
findFailure, findSuccess, getUserDatabase
 
Methods inherited from class org.apache.struts.action.Action
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LANGUAGE

private static final String LANGUAGE

Parameter for @link(java.util.Locale) language property. ["language"]

See Also:
Constant Field Values

COUNTRY

private static final String COUNTRY

Parameter for @link(java.util.Locale) country property. ["country"]

See Also:
Constant Field Values

PAGE

private static final String PAGE

Parameter for response page URI. ["page"]

See Also:
Constant Field Values

FORWARD

private static final String FORWARD

Parameter for response forward name. ["forward"]

See Also:
Constant Field Values

LOCALE_LOG

private static final String LOCALE_LOG

Logging message if LocaleAction is missing a target parameter.

See Also:
Constant Field Values
Constructor Detail

LocaleAction

public LocaleAction()
Method Detail

isBlank

private boolean isBlank(String string)

Return true if parameter is null or trims to empty.

Parameters:
string - The string to text; may be null
Returns:
true if parameter is null or empty

execute

public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping,
                                                      org.apache.struts.action.ActionForm form,
                                                      javax.servlet.http.HttpServletRequest request,
                                                      javax.servlet.http.HttpServletResponse response)
                                               throws Exception

Change the user's Struts @link(java.util.Locale) based on request parameters for "language", "country". After setting the Locale, control is forwarded to an URI path indicated by a "page" parameter, or a forward indicated by a "forward" parameter, or to a forward given as the mappings "parameter" property. The response location must be specified one of these ways.

Parameters:
mapping - The ActionMapping used to select this instance
form - The optional ActionForm bean for this request (if any)
request - The HTTP request we are processing
response - The HTTP response we are creating
Returns:
An ActionForward indicate the resources that will render the response
Throws:
Exception - if an input/output error or servlet exception occurs


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.