org.apache.struts.config
Class ConfigHelper

java.lang.Object
  |
  +--org.apache.struts.config.ConfigHelper
All Implemented Interfaces:
ConfigHelperInterface

public class ConfigHelper
extends java.lang.Object
implements ConfigHelperInterface

NOTE: THIS CLASS IS UNDER ACTIVE DEVELOPMENT. THE CURRENT CODE IS WRITTEN FOR CLARITY NOT EFFICIENCY. NOT EVERY API FUNCTION HAS BEEN IMPLEMENTED YET. A helper object to expose the Struts shared resources, which are be stored in the application, session, or request contexts, as appropriate. An instance should be created for each request processed. The methods which return resources from the request or session contexts are not thread-safe. Provided for use by other servlets in the application so they can easily access the Struts shared resources. The resources are stored under attributes in the application, session, or request contexts. The ActionConfig methods simply return the resources from under the context and key used by the Struts ActionServlet when the resources are created.

Since:
1.1
Version:
$Revision: 1.1 $ $Date$
Author:
Ted Husted, Luis Arias

Field Summary
private  javax.servlet.ServletContext application
          The application associated with this instance.
private  ActionForward forward
          The forward associated with this instance.
private  javax.servlet.http.HttpServletRequest request
          The request associated with this instance.
private  javax.servlet.http.HttpServletResponse response
          The response associated with this instance.
private  javax.servlet.http.HttpSession session
          The session associated with this instance.
 
Constructor Summary
ConfigHelper()
           
ConfigHelper(javax.servlet.ServletContext application, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 
Method Summary
 java.lang.String action(java.lang.String path)
          Wrapper for getAction(String)
 java.lang.String errorOutput()
          Wrapper for getErrorMarkup()
 java.lang.String errorOutput(java.lang.String property)
          Wrapper for getErrorMarkup(String)
 java.util.Iterator errors()
          Wrapper for getErrors()
 java.util.Iterator errors(java.lang.String property)
          Wrapper for getErrors(String)
 boolean errorsEmpty()
          Wrapper for getErrorEmpty()
 int errorSize()
          Alias for getErrorSize()
 int errorSize(java.lang.String property)
          Wrapper for getErrorSize(String)
 java.lang.String getAction(java.lang.String path)
          Return the URL for the specified ActionMapping, otherwise return null.
 ActionErrors getActionErrors()
          The org.apache.struts.action.ActionErrors object, for this request.
 ActionForm getActionForm()
           
 ActionFormBeans getActionFormBeans()
          The org.apache.struts.action.ActionFormBeans collection for this application.
 ActionForward getActionForward(java.lang.String name)
          Return the forwarding associated with the specified logical name, if any; otherwise return null.
 ActionForwards getActionForwards()
          The org.apache.struts.action.ActionForwards collection for this application.
 ActionMapping getActionMapping(java.lang.String path)
          Return the mapping associated with the specified request path, if any; otherwise return null.
 java.lang.String getActionMappingName(java.lang.String action)
          Return the form action converted into an action mapping path.
 ActionMappings getActionMappings()
          The context attributes key under which our org.apache.struts.action.ActionMappings collection is normally stored, unless overridden when initializing our ActionServlet.
 java.lang.String getActionMappingURL(java.lang.String action)
          Return the form action converted into a server-relative URL.
 ActionMessages getActionMessages()
          The org.apache.struts.action.ActionFormBeans collection for this application.
 java.lang.String getBaseRef()
          Renders the reference for a HTML element.
 javax.sql.DataSource getDataSource()
          The strong>default configured data source (which must implement javax.sql.DataSource), if one is configured for this application.
 java.lang.String getEncodeURL(java.lang.String url)
          Return the url encoded to maintain the user session, if any.
 java.lang.String getErrorOutput()
          Wrapper for getErrorMarkup(null)
 java.lang.String getErrorOutput(java.lang.String property)
          Returns the errors.header, any errors, and the errors.footer.
 java.util.Iterator getErrors()
          Return the error messages
 java.util.Iterator getErrors(java.lang.String property)
          Return an ActionError for a property
 boolean getErrorsEmpty()
          Return true if there are no errors queued
 int getErrorSize()
          Return the number of error messages.
 int getErrorSize(java.lang.String property)
          Return the number of error messages.
 java.lang.Throwable getException()
          The runtime JspException that may be been thrown by a Struts tag extension, or compatible presentation extension, and placed in the request.
 ActionFormBean getFormBean(java.lang.String name)
          Return the form bean definition associated with the specified logical name, if any; otherwise return null.
 java.lang.String getLink(java.lang.String name)
          Return the path for the specified forward, otherwise return null.
 java.util.Locale getLocale()
          The java.util.Locale for the user, if any.
 ActionMapping getMapping()
          The org.apache.struts.ActionMapping instance for this request.
 java.lang.String getMessage(java.lang.String key)
          Return the localized message for the specified key, otherwise return null.
 java.lang.String getMessage(java.lang.String key, java.lang.Object[] args)
          Look up and return a message string, based on the specified parameters.
 MessageResources getMessageResources()
          The application resources for this application.
 MultipartRequestWrapper getMultipartRequestWrapper()
          The multipart object for this request.
 java.lang.String getOrigRef()
          Renders the reference for a HTML element
 java.lang.String getServletMapping()
          The path-mapped pattern (/action/*) or extension mapped pattern ((*.do) used to determine our Action URIs in this application.
 java.lang.String getToken()
          The transaction token stored in this session, if it is used.
 boolean isMessage(java.lang.String key)
          Return true if a message string for the specified message key is present for the user's Locale.
 java.lang.String link(java.lang.String name)
          Wrapper for getLink(String)
 java.lang.String message(java.lang.String key)
          Wrapper for getMessage(String)
 java.lang.String message(java.lang.String key, java.lang.Object[] args)
          Wrapper for getMessage(String,Object[])
 void setApplication(javax.servlet.ServletContext application)
          Set the application associated with this instance.
 void setForward(ActionForward forward)
          Set the forward associated with this instance.
 void setRequest(javax.servlet.http.HttpServletRequest request)
          Set the request associated with this object.
 void setResources(javax.servlet.ServletContext application, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Set the application and request for this object instance.
 void setResponse(javax.servlet.http.HttpServletResponse response)
          Set the response associated with this isntance.
 void setSession(javax.servlet.http.HttpSession session)
          Set the session associated with this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

application

private javax.servlet.ServletContext application
The application associated with this instance.


session

private javax.servlet.http.HttpSession session
The session associated with this instance.


request

private javax.servlet.http.HttpServletRequest request
The request associated with this instance.


response

private javax.servlet.http.HttpServletResponse response
The response associated with this instance.


forward

private ActionForward forward
The forward associated with this instance.

Constructor Detail

ConfigHelper

public ConfigHelper()

ConfigHelper

public ConfigHelper(javax.servlet.ServletContext application,
                    javax.servlet.http.HttpServletRequest request,
                    javax.servlet.http.HttpServletResponse response)
Method Detail

setApplication

public void setApplication(javax.servlet.ServletContext application)
Set the application associated with this instance. [servlet.getServletContext()]


setSession

public void setSession(javax.servlet.http.HttpSession session)
Set the session associated with this instance.


setRequest

public void setRequest(javax.servlet.http.HttpServletRequest request)
Set the request associated with this object. Session object is also set or cleared.


setResponse

public void setResponse(javax.servlet.http.HttpServletResponse response)
Set the response associated with this isntance. Session object is also set or cleared.


setForward

public void setForward(ActionForward forward)
Set the forward associated with this instance.


setResources

public void setResources(javax.servlet.ServletContext application,
                         javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response)
Set the application and request for this object instance. The ServletContext can be set by any servlet in the application. The request should be the instant request. Most of the other methods retrieve their own objects by reference to the application, request, or session attributes. Do not call other methods without setting these first! This is also called by the convenience constructor.

Parameters:
application - - The associated ServletContext.
request - - The associated HTTP request.
response - - The associated HTTP response.

getDataSource

public javax.sql.DataSource getDataSource()
The strong>default configured data source (which must implement javax.sql.DataSource), if one is configured for this application.

Specified by:
getDataSource in interface ConfigHelperInterface

getActionMessages

public ActionMessages getActionMessages()
Description copied from interface: ConfigHelperInterface
The org.apache.struts.action.ActionFormBeans collection for this application.

Specified by:
getActionMessages in interface ConfigHelperInterface

getActionFormBeans

public ActionFormBeans getActionFormBeans()
The org.apache.struts.action.ActionFormBeans collection for this application.

Specified by:
getActionFormBeans in interface ConfigHelperInterface

getActionForwards

public ActionForwards getActionForwards()
The org.apache.struts.action.ActionForwards collection for this application.

Specified by:
getActionForwards in interface ConfigHelperInterface

getActionMappings

public ActionMappings getActionMappings()
The context attributes key under which our org.apache.struts.action.ActionMappings collection is normally stored, unless overridden when initializing our ActionServlet.

Specified by:
getActionMappings in interface ConfigHelperInterface

getMessageResources

public MessageResources getMessageResources()
The application resources for this application.

Specified by:
getMessageResources in interface ConfigHelperInterface

getServletMapping

public java.lang.String getServletMapping()
The path-mapped pattern (/action/*) or extension mapped pattern ((*.do) used to determine our Action URIs in this application.

Specified by:
getServletMapping in interface ConfigHelperInterface

getLocale

public java.util.Locale getLocale()
The java.util.Locale for the user, if any. If a default locale object is not in the user's session, the system default locale is returned. If used, the user locale is typically set during login processing under the key Globals.LOCALE_KEY.

Specified by:
getLocale in interface ConfigHelperInterface

getToken

public java.lang.String getToken()
The transaction token stored in this session, if it is used.

Specified by:
getToken in interface ConfigHelperInterface

getActionErrors

public ActionErrors getActionErrors()
The org.apache.struts.action.ActionErrors object, for this request.

Specified by:
getActionErrors in interface ConfigHelperInterface

getException

public java.lang.Throwable getException()
The runtime JspException that may be been thrown by a Struts tag extension, or compatible presentation extension, and placed in the request.

Specified by:
getException in interface ConfigHelperInterface

getMultipartRequestWrapper

public MultipartRequestWrapper getMultipartRequestWrapper()
The multipart object for this request.

Specified by:
getMultipartRequestWrapper in interface ConfigHelperInterface

getMapping

public ActionMapping getMapping()
The org.apache.struts.ActionMapping instance for this request.

Specified by:
getMapping in interface ConfigHelperInterface

isMessage

public boolean isMessage(java.lang.String key)
Return true if a message string for the specified message key is present for the user's Locale.

Specified by:
isMessage in interface ConfigHelperInterface
Parameters:
key - Message key

getActionForm

public ActionForm getActionForm()
Specified by:
getActionForm in interface ConfigHelperInterface

getFormBean

public ActionFormBean getFormBean(java.lang.String name)
Return the form bean definition associated with the specified logical name, if any; otherwise return null.

Specified by:
getFormBean in interface ConfigHelperInterface
Parameters:
name - Logical name of the requested form bean definition

getActionForward

public ActionForward getActionForward(java.lang.String name)
Return the forwarding associated with the specified logical name, if any; otherwise return null.

Specified by:
getActionForward in interface ConfigHelperInterface
Parameters:
name - Logical name of the requested forwarding

getActionMapping

public ActionMapping getActionMapping(java.lang.String path)
Return the mapping associated with the specified request path, if any; otherwise return null.

Specified by:
getActionMapping in interface ConfigHelperInterface
Parameters:
path - Request path for which a mapping is requested

getActionMappingName

public java.lang.String getActionMappingName(java.lang.String action)
Return the form action converted into an action mapping path. The value of the action property is manipulated as follows in computing the name of the requested mapping:

Specified by:
getActionMappingName in interface ConfigHelperInterface

getActionMappingURL

public java.lang.String getActionMappingURL(java.lang.String action)
Return the form action converted into a server-relative URL.

Specified by:
getActionMappingURL in interface ConfigHelperInterface

getEncodeURL

public java.lang.String getEncodeURL(java.lang.String url)
Return the url encoded to maintain the user session, if any.

Specified by:
getEncodeURL in interface ConfigHelperInterface

getOrigRef

public java.lang.String getOrigRef()
Renders the reference for a HTML element

Specified by:
getOrigRef in interface ConfigHelperInterface

getBaseRef

public java.lang.String getBaseRef()
Renders the reference for a HTML element.

Specified by:
getBaseRef in interface ConfigHelperInterface

getLink

public java.lang.String getLink(java.lang.String name)
Return the path for the specified forward, otherwise return null.

Specified by:
getLink in interface ConfigHelperInterface
Parameters:
name - Name given to local or global forward.

getMessage

public java.lang.String getMessage(java.lang.String key)
Return the localized message for the specified key, otherwise return null.

Specified by:
getMessage in interface ConfigHelperInterface
Parameters:
key - Message key

getMessage

public java.lang.String getMessage(java.lang.String key,
                                   java.lang.Object[] args)
Look up and return a message string, based on the specified parameters.

Specified by:
getMessage in interface ConfigHelperInterface
Parameters:
key - Message key to be looked up and returned
args - Replacement parameters for this message

getAction

public java.lang.String getAction(java.lang.String path)
Return the URL for the specified ActionMapping, otherwise return null.

Specified by:
getAction in interface ConfigHelperInterface
Parameters:
path - Name given to local or global forward.

getErrorSize

public int getErrorSize()
Return the number of error messages.

Specified by:
getErrorSize in interface ConfigHelperInterface

getErrorsEmpty

public boolean getErrorsEmpty()
Return true if there are no errors queued

Specified by:
getErrorsEmpty in interface ConfigHelperInterface

getErrors

public java.util.Iterator getErrors()
Return the error messages

Specified by:
getErrors in interface ConfigHelperInterface

getErrors

public java.util.Iterator getErrors(java.lang.String property)
Return an ActionError for a property

Specified by:
getErrors in interface ConfigHelperInterface
Parameters:
property - Property name

getErrorSize

public int getErrorSize(java.lang.String property)
Return the number of error messages.

Specified by:
getErrorSize in interface ConfigHelperInterface
Parameters:
property - Property name

getErrorOutput

public java.lang.String getErrorOutput(java.lang.String property)
Returns the errors.header, any errors, and the errors.footer.

Specified by:
getErrorOutput in interface ConfigHelperInterface
Parameters:
property - Property name

getErrorOutput

public java.lang.String getErrorOutput()
Wrapper for getErrorMarkup(null)

Specified by:
getErrorOutput in interface ConfigHelperInterface

link

public java.lang.String link(java.lang.String name)
Wrapper for getLink(String)

Parameters:
name - Name given to local or global forward.

message

public java.lang.String message(java.lang.String key)
Wrapper for getMessage(String)

Parameters:
key - Message key

message

public java.lang.String message(java.lang.String key,
                                java.lang.Object[] args)
Wrapper for getMessage(String,Object[])

Parameters:
key - Message key to be looked up and returned
args - Replacement parameters for this message

action

public java.lang.String action(java.lang.String path)
Wrapper for getAction(String)

Parameters:
path - Name given to local or global forward.

errorSize

public int errorSize()
Alias for getErrorSize()


errorsEmpty

public boolean errorsEmpty()
Wrapper for getErrorEmpty()


errors

public java.util.Iterator errors()
Wrapper for getErrors()


errors

public java.util.Iterator errors(java.lang.String property)
Wrapper for getErrors(String)


errorSize

public int errorSize(java.lang.String property)
Wrapper for getErrorSize(String)

Parameters:
property - Property name

errorOutput

public java.lang.String errorOutput(java.lang.String property)
Wrapper for getErrorMarkup(String)


errorOutput

public java.lang.String errorOutput()
Wrapper for getErrorMarkup()



Copyright © 2000-2003 - Apache Software Foundation