com.cc.framework.adapter.struts
Class StrutsFrameworkAdapter

java.lang.Object
  extended bycom.cc.framework.adapter.struts.StrutsFrameworkAdapter
All Implemented Interfaces:
FrameworkAdapter

public class StrutsFrameworkAdapter
extends java.lang.Object
implements FrameworkAdapter

Framework Adapter for the Jakarta Struts Framework

Version:
$Revision: 1.1 $
Author:
Harald Schulz

Field Summary
private static org.apache.commons.logging.Log log
          Log
private  java.lang.String servletMapping
          The servlet mapping of the frontcontroller servlet
 
Constructor Summary
StrutsFrameworkAdapter()
           
 
Method Summary
 void addTransactionToken(javax.servlet.jsp.PageContext pageContext, Hyperlink link)
          Adds the a transaction token (if any) to the given Parameter List.
 java.lang.String applyServletMapping(java.lang.String url)
          Applies the front controllers servlet mapping to the given URL
 ActionPainter createActionPainter(PainterContext ctx, ControlAction action)
          Creates an ActionPainter.
private static java.lang.String getActionMappingName(java.lang.String action)
          Return the form action converted into an action mapping path.
 java.lang.String getActionMappingURL(javax.servlet.jsp.PageContext pageContext, java.lang.String action)
          This Method maps an Action identifier to an URL
 java.lang.String getControlAction(javax.servlet.jsp.PageContext pageContext, javax.servlet.jsp.tagext.TagSupport taghandler)
          Gets the default Action which should be used to forward requests from this control.
 MessageDataModel getMessages(javax.servlet.jsp.PageContext pageContext, Severity severity)
          Returns the Framework Messages
protected  org.apache.struts.config.ModuleConfig getModuleConfig(java.lang.String module, HttpContext context)
          Return the ModuleConfig object for the given prefix if it exists, null if otherwise.
 boolean hasMessages(javax.servlet.jsp.PageContext pageContext, Severity severity, java.lang.String property)
          Checks for framework messages
 java.util.Locale localeFromName(HttpContext context, java.lang.String localeName)
          Gets the Locale Object from a Locale Name
 java.util.Locale localeFromName(javax.servlet.jsp.PageContext pageContext, java.lang.String localeName)
          Gets the Locale Object from a Locale Name
 java.lang.String localizeKey(HttpContext context, java.lang.String resourceKey, java.util.Locale locale, boolean returnNull)
          Localizes a string depending on the localization settings of the Painter context.
 java.lang.String localizeKey(javax.servlet.jsp.PageContext pageContext, java.lang.String resourceKey, java.util.Locale locale, boolean returnNull)
          Localizes a string depending on the localization settings of the Painter context.
 java.lang.Object lookupBean(javax.servlet.jsp.PageContext pageContext, java.lang.String name, java.lang.String property, HttpScope scope)
          Lookup a Javabean for use in a JSP tag handler
 java.lang.Object lookupBean(javax.servlet.jsp.PageContext pageContext, javax.servlet.jsp.tagext.TagSupport taghandler, java.lang.String name, java.lang.String property, HttpScope scope)
          Does a lookup for the specified Java bean
protected  org.apache.struts.util.MessageResources retrieveMessageResources(HttpContext context, java.lang.String bundle)
          Returns the appropriate MessageResources object for the current struts module and the given bundle.
protected  org.apache.struts.util.MessageResources retrieveMessageResources(javax.servlet.jsp.PageContext pageContext, java.lang.String bundle)
          Deprecated.  
 void setServletMapping(java.lang.String mapping)
          Sets the frontcontrollers servlet mapping.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static transient org.apache.commons.logging.Log log
Log


servletMapping

private java.lang.String servletMapping
The servlet mapping of the frontcontroller servlet

Constructor Detail

StrutsFrameworkAdapter

public StrutsFrameworkAdapter()
Method Detail

setServletMapping

public void setServletMapping(java.lang.String mapping)
Sets the frontcontrollers servlet mapping. Call this method if your servlet mapping differs from "*.do"

Parameters:
mapping - Servlet mapping string

applyServletMapping

public java.lang.String applyServletMapping(java.lang.String url)
Description copied from interface: FrameworkAdapter
Applies the front controllers servlet mapping to the given URL

Specified by:
applyServletMapping in interface FrameworkAdapter
Parameters:
url - the URL to apply the servlet mapping to (e.g. "/main")
Returns:
mapped URL (e.g. "/main.do")
See Also:
FrameworkAdapter.applyServletMapping(java.lang.String)

addTransactionToken

public void addTransactionToken(javax.servlet.jsp.PageContext pageContext,
                                Hyperlink link)
Adds the a transaction token (if any) to the given Parameter List. The Transaction token is used to track form re-submissions.

Specified by:
addTransactionToken in interface FrameworkAdapter
Parameters:
pageContext - Search the context's scopes for the resources.
link - Hyperlink

retrieveMessageResources

protected org.apache.struts.util.MessageResources retrieveMessageResources(javax.servlet.jsp.PageContext pageContext,
                                                                           java.lang.String bundle)
Deprecated.  

Returns the appropriate MessageResources object for the current struts module and the given bundle.

Parameters:
pageContext - Search the context's scopes for the resources.
bundle - The bundle name to look for. If this is null, the default bundle name is used.
Returns:
MessageResources The bundle's resources stored in some scope.

getModuleConfig

protected org.apache.struts.config.ModuleConfig getModuleConfig(java.lang.String module,
                                                                HttpContext context)
Return the ModuleConfig object for the given prefix if it exists, null if otherwise.

Parameters:
module - The module prefix
Returns:
the ModuleConfig object

retrieveMessageResources

protected org.apache.struts.util.MessageResources retrieveMessageResources(HttpContext context,
                                                                           java.lang.String bundle)
Returns the appropriate MessageResources object for the current struts module and the given bundle.

Parameters:
context - Search the context's scopes for the resources.
bundle - The bundle name to look for. If this is null, the default bundle name is used.
Returns:
MessageResources The bundle's resources stored in some scope.

localizeKey

public java.lang.String localizeKey(javax.servlet.jsp.PageContext pageContext,
                                    java.lang.String resourceKey,
                                    java.util.Locale locale,
                                    boolean returnNull)
Description copied from interface: FrameworkAdapter
Localizes a string depending on the localization settings of the Painter context. A key is searched in the following order:
  1. If no user defined resource bundle is used. The resource is searched under the STRUTS_MESSAGES_KEY.
  2. If an user defined resource bundle is used (key@bundle) the resource is searched in the specified resource bundle.
  3. If the key was not found before, the resource is searched in the framework resource bundle under the key Globals.MESSAGE.

Specified by:
localizeKey in interface FrameworkAdapter
Parameters:
pageContext - JSP Page Context
resourceKey - The resource key.
locale - Locale or null
returnNull - controls whether to return null or a not present indicator
Returns:
localized String
See Also:
FrameworkAdapter.localizeKey(javax.servlet.jsp.PageContext, java.lang.String, java.util.Locale, boolean)

localizeKey

public java.lang.String localizeKey(HttpContext context,
                                    java.lang.String resourceKey,
                                    java.util.Locale locale,
                                    boolean returnNull)
Description copied from interface: FrameworkAdapter
Localizes a string depending on the localization settings of the Painter context. A key is searched in the following order:
  1. If no user defined resource bundle is used. The resource is searched under the STRUTS_MESSAGES_KEY.
  2. If an user defined resource bundle is used (key@bundle) the resource is searched in the specified resource bundle.
  3. If the key was not found before, the resource is searched in the framework resource bundle under the key Globals.MESSAGE.

Specified by:
localizeKey in interface FrameworkAdapter
Parameters:
context - JSP Page Context
resourceKey - The resource key.
locale - Locale or null
returnNull - controls whether to return null or a not present indicator
Returns:
localized String
See Also:
FrameworkAdapter.localizeKey(com.cc.framework.http.HttpContext, java.lang.String, java.util.Locale, boolean)

getActionMappingName

private static 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:

Parameters:
action - Action
Returns:
String

getActionMappingURL

public java.lang.String getActionMappingURL(javax.servlet.jsp.PageContext pageContext,
                                            java.lang.String action)
Description copied from interface: FrameworkAdapter
This Method maps an Action identifier to an URL

Specified by:
getActionMappingURL in interface FrameworkAdapter
Parameters:
pageContext - PageContext
action - Action
Returns:
String
See Also:
FrameworkAdapter.getActionMappingURL(javax.servlet.jsp.PageContext, java.lang.String), TagUtils.getActionMappingURL(java.lang.String, javax.servlet.jsp.PageContext)

localeFromName

public java.util.Locale localeFromName(javax.servlet.jsp.PageContext pageContext,
                                       java.lang.String localeName)
Description copied from interface: FrameworkAdapter
Gets the Locale Object from a Locale Name

Specified by:
localeFromName in interface FrameworkAdapter
Parameters:
pageContext - JSP Page Context
localeName - The Name
Returns:
Locale Object or null
See Also:
FrameworkAdapter.localeFromName(javax.servlet.jsp.PageContext, java.lang.String)

localeFromName

public java.util.Locale localeFromName(HttpContext context,
                                       java.lang.String localeName)
Description copied from interface: FrameworkAdapter
Gets the Locale Object from a Locale Name

Specified by:
localeFromName in interface FrameworkAdapter
Parameters:
context - JSP Page Context
localeName - The Name
Returns:
Locale Object or null
See Also:
FrameworkAdapter.localeFromName(com.cc.framework.http.HttpContext, java.lang.String)

getControlAction

public java.lang.String getControlAction(javax.servlet.jsp.PageContext pageContext,
                                         javax.servlet.jsp.tagext.TagSupport taghandler)
Gets the default Action which should be used to forward requests from this control. This action is used when the action-property of the control is not set

Specified by:
getControlAction in interface FrameworkAdapter
Parameters:
pageContext - The JSP Page context
taghandler - The JSP Tag
Returns:
String or null

lookupBean

public java.lang.Object lookupBean(javax.servlet.jsp.PageContext pageContext,
                                   javax.servlet.jsp.tagext.TagSupport taghandler,
                                   java.lang.String name,
                                   java.lang.String property,
                                   HttpScope scope)
                            throws java.lang.Exception
Does a lookup for the specified Java bean

Parameters:
pageContext - JSP Page Context
taghandler - The Tag Handler that calls this method
name - The Bean's name
property - The property
scope - The scope where the bean is stored
Returns:
Bean
Throws:
java.lang.Exception - Is thrown in case of an error

lookupBean

public java.lang.Object lookupBean(javax.servlet.jsp.PageContext pageContext,
                                   java.lang.String name,
                                   java.lang.String property,
                                   HttpScope scope)
                            throws java.lang.Exception
Description copied from interface: FrameworkAdapter
Lookup a Javabean for use in a JSP tag handler

Specified by:
lookupBean in interface FrameworkAdapter
Parameters:
pageContext - JSP page context
name - Name of the bean
property - Name of a beans property
scope - the scope where the bean should be located
Returns:
Java Bean or null
Throws:
java.lang.Exception - is thrown in case of an error
See Also:
FrameworkAdapter.lookupBean(javax.servlet.jsp.PageContext, java.lang.String, java.lang.String, com.cc.framework.http.HttpScope)

getMessages

public MessageDataModel getMessages(javax.servlet.jsp.PageContext pageContext,
                                    Severity severity)
                             throws java.lang.Exception
Description copied from interface: FrameworkAdapter
Returns the Framework Messages

Specified by:
getMessages in interface FrameworkAdapter
Parameters:
pageContext - JSP Page Context
severity - Severity
Returns:
MessageDataModel
Throws:
java.lang.Exception - If an error occurs while loading the Message List
See Also:
FrameworkAdapter.getMessages(javax.servlet.jsp.PageContext, com.cc.framework.common.Severity)

hasMessages

public boolean hasMessages(javax.servlet.jsp.PageContext pageContext,
                           Severity severity,
                           java.lang.String property)
Description copied from interface: FrameworkAdapter
Checks for framework messages

Specified by:
hasMessages in interface FrameworkAdapter
Parameters:
pageContext - JSP Page Context
severity - Severity
property - Property name or null
Returns:
boolean
See Also:
FrameworkAdapter.hasMessages(javax.servlet.jsp.PageContext, com.cc.framework.common.Severity, java.lang.String)

createActionPainter

public ActionPainter createActionPainter(PainterContext ctx,
                                         ControlAction action)
Description copied from interface: FrameworkAdapter
Creates an ActionPainter. The Painter is used by Controls to render Actions into the user interface

Specified by:
createActionPainter in interface FrameworkAdapter
Parameters:
ctx - The Painter Context
action - ControlAction
Returns:
ActionPainter
See Also:
FrameworkAdapter.createActionPainter(com.cc.framework.ui.painter.PainterContext, com.cc.framework.ui.control.ControlAction)


Copyright © 2000-2005 SCC Informationssysteme GmbH. All Rights Reserved.