IT.CappuccinoNet  
StrutsCX v0.8.3
   

com.cappuccinonet.strutscx.action
Class StrutsCXBaseActionHelper

java.lang.Object
  |
  +--com.cappuccinonet.strutscx.action.StrutsCXBaseActionHelper

public class StrutsCXBaseActionHelper
extends java.lang.Object

This class helps to keep the BaseAction cleaner and is responsible to set and check a couple parameters to the HttpServletRequest, the HttpSession or the ServletContext.

ServletContext:

  1. StrutsCXConstants.HTTP_DOMAIN_ADDRESS
  2. StrutsCXConstants.ROOTPATH
  3. StrutsCXConstants.PROJECTNAME
  4. StrutsCXConstants.RESSOURCEPROPERTIES_FILESxx
  5. StrutsCXConstants.DOMAINPARAMS_FLAG - this flag marks that the parameters are allready set.

HttpSession:

  1. StrutsCXConstants.DOMAIN
  2. StrutsCXConstants.HTTP_DOMAIN_ADDRESS
  3. StrutsCXConstants.PORT
  4. StrutsCXConstants.ROOTPATH
  5. StrutsCXConstants.PROJECTNAME
  6. StrutsCXConstants.PROJECTNAME
  7. StrutsCXConstants.DATE_TODAY
  8. StrutsCXConstants.THIS_YEAR
  9. StrutsCXConstants.LOCALE

HttpServletRequest:

  1. StrutsCXConstants.XML_ENTRY_ID
  2. StrutsCXConstants.CHARSET_KEY

The reason for doing all this is, that we do need serialize some of these parameters into the output XML document. Check out the XSLTDocumentBuilder for more details on this.

Caching & Performance Tuning:
The variables for the view are read once at first call to the BaseAction and saved in the ServletContext. NOTE: To affect changes to them the Servlet Engine need to be restarted.

Version:
v0.8, 2003.02.01
Author:
Bernhard Woehrlin, IT.CappuccinoNet.com

Field Summary
private  java.lang.String dateToday
          The date today.
private static Logger logger
          The logger - it is visible to all subclasses.
private  java.lang.String THIS_CLASS
          A String with this Classname used for system messages
private  java.lang.String thisYear
          The actual year.
 
Constructor Summary
StrutsCXBaseActionHelper()
           
 
Method Summary
 java.lang.String getCharset(HttpServletRequest request, com.oreilly.javaxml2.XMLProperties properties, java.util.Locale locale)
          Sets the users prefered charset to the request.
private  java.lang.String getDateToday(HttpSession session, java.util.Locale locale)
          Gets the date today.
 int getEntryId(HttpServletRequest request)
          Reads the entryId Parameter out of the request and writes it back to it as a Attribute.
 java.util.Locale getLocale(HttpServletRequest request, HttpSession session)
          Updates the Locale.
 java.lang.String getPersisttype(HttpServletRequest request, com.oreilly.javaxml2.XMLProperties properties)
          EXPERIMENTAL: Method getPersisttype.
 java.lang.String getViewtype(HttpServletRequest request, com.oreilly.javaxml2.XMLProperties properties)
          EXPERIMENTAL: Method getViewtype.
private  java.lang.String getYear(HttpSession session)
          Gets the actual year.
private  void loadRessourcePropertiesFiles(ServletConfig config, com.oreilly.javaxml2.XMLProperties properties)
          This method loads all variables files we pointed to in the properties.xml and saves them under an unique identifier in the ServletContext.
 void setBasicDomainParameters(HttpServletRequest request, HttpSession session, ServletConfig config, com.oreilly.javaxml2.XMLProperties properties)
          A convenience method which combines call to a couple of other methodes to set and check the parameters into the ServletContext and the HttpSession.
 void setDateStrings(HttpSession session, java.util.Locale locale)
          A convenience method which does nothing else than calling the getDateToday() and the getYear() methods.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THIS_CLASS

private java.lang.String THIS_CLASS
A String with this Classname used for system messages


logger

private static Logger logger
The logger - it is visible to all subclasses.


dateToday

private java.lang.String dateToday
The date today.


thisYear

private java.lang.String thisYear
The actual year.

Constructor Detail

StrutsCXBaseActionHelper

public StrutsCXBaseActionHelper()
Method Detail

setBasicDomainParameters

public void setBasicDomainParameters(HttpServletRequest request,
                                     HttpSession session,
                                     ServletConfig config,
                                     com.oreilly.javaxml2.XMLProperties properties)
                              throws StrutsCXException
A convenience method which combines call to a couple of other methodes to set and check the parameters into the ServletContext and the HttpSession.

See above for a list of parameters this method organizes.

Parameters:
request - the HttpServletRequest
session - the HttpSession
config - the ServletConfig
properties - the XMLProperties
StrutsCXException
See Also:
StrutsCXConstants, StrutsCXPropertiesReader

getEntryId

public int getEntryId(HttpServletRequest request)
Reads the entryId Parameter out of the request and writes it back to it as a Attribute. The entryId marks a dataset or tag we will manipulate.

Parameters:
request - the HttpServletRequest
Returns:
int the entry ID.
See Also:
StrutsCXConstants

getDateToday

private java.lang.String getDateToday(HttpSession session,
                                      java.util.Locale locale)
Gets the date today. If this is already done in this session it skips this step. NOTE: Changes to the properties.xml afford to reload the application!

Parameters:
session -
locale -
Returns:
String the date today
See Also:
StrutsCXDateString, StrutsCXConstants

setDateStrings

public void setDateStrings(HttpSession session,
                           java.util.Locale locale)
A convenience method which does nothing else than calling the getDateToday() and the getYear() methods.

Parameters:
session -
locale -
See Also:
getDateToday, getYear

getYear

private java.lang.String getYear(HttpSession session)
Gets the actual year. If this is already done in this session it skips this step. NOTE: Changes to the properties.xml afford to reload the application!

Parameters:
session - the HttpSession
Returns:
String the actual year.
See Also:
StrutsCXDateString, StrutsCXConstants

getLocale

public java.util.Locale getLocale(HttpServletRequest request,
                                  HttpSession session)
Updates the Locale. If no Locale is definet than it will default to english "en".

Parameters:
request - the HttpServletRequest
session - the HttpSession
Returns:
String the locale as String
See Also:
StrutsCXConstants

getCharset

public java.lang.String getCharset(HttpServletRequest request,
                                   com.oreilly.javaxml2.XMLProperties properties,
                                   java.util.Locale locale)
                            throws StrutsCXException
Sets the users prefered charset to the request.

Parameters:
request - the HttpServletRequest
properties - the XMLProperties, hence the properties.xml
locale - a string with the locale parameter *
Returns:
String the charset as a String
Throws:
StrutsCXException - if charset value is missing in the properties.xml

getPersisttype

public java.lang.String getPersisttype(HttpServletRequest request,
                                       com.oreilly.javaxml2.XMLProperties properties)
EXPERIMENTAL: Method getPersisttype. Sets the persistence type to a default value defined as PERSIST_KEY in the Constants class.

Parameters:
request -
properties -
Returns:
String

getViewtype

public java.lang.String getViewtype(HttpServletRequest request,
                                    com.oreilly.javaxml2.XMLProperties properties)
EXPERIMENTAL: Method getViewtype. Sets the view to a default value defined as VIEW_KEY in the Constants class.

Parameters:
request -
properties -
Returns:
String

loadRessourcePropertiesFiles

private void loadRessourcePropertiesFiles(ServletConfig config,
                                          com.oreilly.javaxml2.XMLProperties properties)
                                   throws ServletException
This method loads all variables files we pointed to in the properties.xml and saves them under an unique identifier in the ServletContext.

NOTE: Changes to the variables_xx.xml files afford to reload the servlet container!

Parameters:
config - the ServletConfig
properties - the XMLProperties
Throws:
ServletException - if a servlet exception occurs.

IT.CappuccinoNet  
StrutsCX v0.8.3
   

© 2002, IT.CappuccinoNet.com - compiled 20020207:2326