org.apache.struts.config

Class ConfigHelper

public class ConfigHelper extends 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: Struts 1.1

Version: $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $

Field Summary
ServletContextapplication
The application associated with this instance.
ActionForwardforward
The forward associated with this instance.
HttpServletRequestrequest
The request associated with this instance.
HttpServletResponseresponse
The response associated with this instance.
HttpSessionsession
The session associated with this instance.
Constructor Summary
ConfigHelper()
ConfigHelper(ServletContext application, HttpServletRequest request, HttpServletResponse response)
Method Summary
Stringaction(String path)
Wrapper for getAction(String)
StringgetAction(String path)
Return the URL for the specified ActionMapping, otherwise return null.
ActionFormgetActionForm()
ActionForwardgetActionForward(String name)
Return the forwarding associated with the specified logical name, if any; otherwise return null.
ActionMappinggetActionMapping(String path)
Return the mapping associated with the specified request path, if any; otherwise return null.
StringgetActionMappingName(String action)
Return the form action converted into an action mapping path.
StringgetActionMappingURL(String action)
Return the form action converted into a server-relative URL.
ActionMessagesgetActionMessages()
StringgetBaseRef()
Renders the reference for a HTML element.
DataSourcegetDataSource()
The default configured data source (which must implement javax.sql.DataSource), if one is configured for this application.
StringgetEncodeURL(String url)
Return the url encoded to maintain the user session, if any.
ThrowablegetException()
The runtime JspException that may be been thrown by a Struts tag extension, or compatible presentation extension, and placed in the request.
ActionFormBeangetFormBean(String name)
Return the form bean definition associated with the specified logical name, if any; otherwise return null.
StringgetLink(String name)
Return the path for the specified forward, otherwise return null.
ActionMappinggetMapping()
The org.apache.struts.ActionMapping instance for this request.
StringgetMessage(String key)
Return the localized message for the specified key, otherwise return null.
StringgetMessage(String key, Object[] args)
Look up and return a message string, based on the specified parameters.
MessageResourcesgetMessageResources()
The application resources for this application.
MultipartRequestWrappergetMultipartRequestWrapper()
The multipart object for this request.
StringgetOrigRef()
Renders the reference for a HTML element
StringgetServletMapping()
The path-mapped pattern (/action/*) or extension mapped pattern ((*.do) used to determine our Action URIs in this application.
StringgetToken()
The transaction token stored in this session, if it is used.
booleanisMessage(String key)
Return true if a message string for the specified message key is present for the user's Locale.
Stringlink(String name)
Wrapper for getLink(String)
Stringmessage(String key)
Wrapper for getMessage(String)
Stringmessage(String key, Object[] args)
Wrapper for getMessage(String,Object[])
voidsetApplication(ServletContext application)
Set the application associated with this instance. [servlet.getServletContext()]
voidsetForward(ActionForward forward)
Set the forward associated with this instance.
voidsetRequest(HttpServletRequest request)
Set the request associated with this object.
voidsetResources(ServletContext application, HttpServletRequest request, HttpServletResponse response)
Set the application and request for this object instance.
voidsetResponse(HttpServletResponse response)
Set the response associated with this isntance.
voidsetSession(HttpSession session)
Set the session associated with this instance.

Field Detail

application

private ServletContext application
The application associated with this instance.

forward

private ActionForward forward
The forward associated with this instance.

request

private HttpServletRequest request
The request associated with this instance.

response

private HttpServletResponse response
The response associated with this instance.

session

private HttpSession session
The session associated with this instance.

Constructor Detail

ConfigHelper

public ConfigHelper()

ConfigHelper

public ConfigHelper(ServletContext application, HttpServletRequest request, HttpServletResponse response)

Method Detail

action

public String action(String path)
Wrapper for getAction(String)

Parameters: path Name given to local or global forward.

getAction

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

Parameters: path Name given to local or global forward.

getActionForm

public ActionForm getActionForm()

getActionForward

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

Parameters: name Logical name of the requested forwarding

getActionMapping

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

Parameters: path Request path for which a mapping is requested

getActionMappingName

public String getActionMappingName(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:

getActionMappingURL

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

getActionMessages

public ActionMessages getActionMessages()

getBaseRef

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

getDataSource

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

getEncodeURL

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

getException

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

getFormBean

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

Parameters: name Logical name of the requested form bean definition

getLink

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

Parameters: name Name given to local or global forward.

getMapping

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

getMessage

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

Parameters: key Message key

getMessage

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

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

getMessageResources

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

getMultipartRequestWrapper

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

getOrigRef

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

getServletMapping

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

getToken

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

isMessage

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

Parameters: key Message key

link

public String link(String name)
Wrapper for getLink(String)

Parameters: name Name given to local or global forward.

message

public String message(String key)
Wrapper for getMessage(String)

Parameters: key Message key

message

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

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

setApplication

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

setForward

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

setRequest

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

setResources

public void setResources(ServletContext application, HttpServletRequest request, 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.

setResponse

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

setSession

public void setSession(HttpSession session)
Set the session associated with this instance.
Copyright B) 2000-2007 - The Apache Software Foundation