org.aris.actionservlet
Class Action

java.lang.Object
  extended by org.aris.actionservlet.Action
All Implemented Interfaces:
java.io.Serializable

public abstract class Action
extends java.lang.Object
implements java.io.Serializable

A base class to create hlServlet actions.

You should inherit this class and implement at least the run() function.

Method Execution during a request to the hlServlet : run() -> ContentType()

Author:
Aris
See Also:
Serialized Form

Field Summary
static int ACTION_HTML
          By returning this in your run() method, you define that the out contains HTML to be returned to the browser.
static int ACTION_NULL
          By returning this in your run() method, you define that no further processing should be done after returning from run().
static int ACTION_REDIRECT
          By returning this in your run() method, you define that the out contains a URL to redirect the browser to.
static int ACTION_XML
          By returning this in your run() method, you define that the xout contains XML to be transformed by an XSLT template.
static java.lang.String lastEditorDepth
           
static java.lang.String lastEditorStr
           
 java.lang.StringBuffer out
          The output StringBuffer.
 javax.servlet.http.HttpServletRequest request
          Servlet request
 javax.servlet.http.HttpServletResponse response
          Servlet response
 javax.servlet.http.HttpSession session
           
 org.jdom.Element xout
          Use this to create your XML tree, when the Action output is ACTION_XML.
 java.lang.String XSLT
          Defines which XSLT to use to transform the XML of the out buffer.
 
Constructor Summary
Action()
          Creates a new instance of hlAction
 
Method Summary
 void clearLastActionsStack()
          Clears the LastActionStackStore stack
 java.lang.String ContentType()
          Defines the content-type of the action's result.
 java.lang.String getActionLink()
          Returns the Action Link {$ACTION}
 Config getConfig()
          Getter for property config.
 java.lang.String getLastAction()
          Returns the lastaction action.
 java.lang.Object getLastActionParam(java.lang.String name)
          gets a parameter for the specific action
 java.lang.Object getLastActionParam(java.lang.String name, int ddepth)
          gets a parameter for the specific -ddepth action
 javax.servlet.http.HttpSession getSession()
          Gets or creates the session.
 javax.servlet.http.HttpSession getSession(boolean create)
          Returns the session.
 org.jdom.Element getXout()
          Getter for property xout.
 java.lang.String getXSLT()
          Override this method and return the XSLT that this action will use.
 java.lang.String requestOrLastActionParam(java.lang.String name)
          Returns the string from request, if it exists, or from lastAction if not
abstract  int run()
          The main method of this action.
 void setAsLastAction(java.lang.String action)
          Sets an action return point.
 void setConfig(Config config)
          Setter for property config.
 void setLastActionParam(java.lang.String name, java.lang.Object value)
           
 void setLastActionParam(java.lang.String name, java.lang.Object value, int ddepth)
          sets a parameter for the specific action
 void setSession(javax.servlet.http.HttpSession session)
          Sets the session.
 void setXout(org.jdom.Element xout)
          Setter for property xout.
 void setXSLT(java.lang.String XSLTFileName)
          Defines which XSLT to use to transform the XML of the out buffer.
 void updateLastActionsDepth()
          Updates the depth of the lastActions.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

session

public javax.servlet.http.HttpSession session

lastEditorStr

public static final java.lang.String lastEditorStr
See Also:
Constant Field Values

lastEditorDepth

public static final java.lang.String lastEditorDepth
See Also:
Constant Field Values

ACTION_NULL

public static final transient int ACTION_NULL
By returning this in your run() method, you define that no further processing should be done after returning from run().

See Also:
Constant Field Values

ACTION_XML

public static final transient int ACTION_XML
By returning this in your run() method, you define that the xout contains XML to be transformed by an XSLT template.

See Also:
Constant Field Values

ACTION_HTML

public static final transient int ACTION_HTML
By returning this in your run() method, you define that the out contains HTML to be returned to the browser.

See Also:
Constant Field Values

ACTION_REDIRECT

public static final transient int ACTION_REDIRECT
By returning this in your run() method, you define that the out contains a URL to redirect the browser to.

See Also:
Constant Field Values

request

public javax.servlet.http.HttpServletRequest request
Servlet request


response

public javax.servlet.http.HttpServletResponse response
Servlet response


out

public java.lang.StringBuffer out
The output StringBuffer. Depending on the result of the run() method, this can have XML, HTML or redirect URL


XSLT

public java.lang.String XSLT
Defines which XSLT to use to transform the XML of the out buffer. Use the setXSLT() method to set it.


xout

public org.jdom.Element xout
Use this to create your XML tree, when the Action output is ACTION_XML.

Constructor Detail

Action

public Action()
Creates a new instance of hlAction

Method Detail

getSession

public javax.servlet.http.HttpSession getSession(boolean create)
Returns the session. If it was not created, then if (create) it will be created.

Parameters:
create - true to create the session if it doesn't exist.
Returns:
HttpSession

getSession

public javax.servlet.http.HttpSession getSession()
Gets or creates the session.

Returns:
HttpSession

setSession

public void setSession(javax.servlet.http.HttpSession session)
Sets the session.

Parameters:
session - HttpSession

ContentType

public java.lang.String ContentType()
Defines the content-type of the action's result.

Returns:
Returns the content type of the object we respond to the browser request. Default: text/html

run

public abstract int run()
The main method of this action.

This method should prepare the appropriate response for the users request.

Returns:
According to the results of the request, this method should return:

1. ACTION_XML if the xout contains XML to be converted to HTML using a XSLT template. run() should call the setXSLT() method to define which template to use.

2. ACTION_HTML if the out buffer contains HTML;

3. ACTION_REDIRECT if the out buffer contains a redirection URL;


setXSLT

public void setXSLT(java.lang.String XSLTFileName)
Defines which XSLT to use to transform the XML of the out buffer.

Parameters:
XSLTFileName - The file name of the XSLT template, relative to $DATA/Templates.. The DATA parameter should point to a valid directory, and be defined at your web.xml.

getXSLT

public java.lang.String getXSLT()
Override this method and return the XSLT that this action will use.

Returns:
The XSLT file's filename. I.e. myxslt.xsl . The myxslt.xsl should be located inside the TEMPLATES directory. Templates directory is located at $DATA/Templates, where $DATA is declared at the web.xml file.

getXout

public org.jdom.Element getXout()
Getter for property xout.

Returns:
Value of property xout.

setXout

public void setXout(org.jdom.Element xout)
Setter for property xout.

Parameters:
xout - New value of property xout.

getConfig

public Config getConfig()
Getter for property config.

Returns:
Value of property config.

setConfig

public void setConfig(Config config)
Setter for property config.

Parameters:
config - New value of property config.

getActionLink

public java.lang.String getActionLink()
Returns the Action Link {$ACTION}

Returns:
The Action URL, i.e. "http://server/Servlet?action="

getLastAction

public java.lang.String getLastAction()
Returns the lastaction action.
Use last actions to create a navigating stack of pages which can use each other.

Returns:
action string

setAsLastAction

public void setAsLastAction(java.lang.String action)
Sets an action return point.
Use last actions to create a navigating stack of pages which can use each other.

Parameters:
action - the action of the editor

setLastActionParam

public void setLastActionParam(java.lang.String name,
                               java.lang.Object value,
                               int ddepth)
sets a parameter for the specific action

Parameters:
name - param name
value - param value

setLastActionParam

public void setLastActionParam(java.lang.String name,
                               java.lang.Object value)

getLastActionParam

public java.lang.Object getLastActionParam(java.lang.String name,
                                           int ddepth)
gets a parameter for the specific -ddepth action

Parameters:
name - name of the parameter
ddepth - currentaction-ddepth action is scanned for this parameter.
Returns:
the param value

getLastActionParam

public java.lang.Object getLastActionParam(java.lang.String name)
gets a parameter for the specific action

Parameters:
name -

requestOrLastActionParam

public java.lang.String requestOrLastActionParam(java.lang.String name)
Returns the string from request, if it exists, or from lastAction if not

Parameters:
name - the param name
Returns:
the param value

updateLastActionsDepth

public void updateLastActionsDepth()
Updates the depth of the lastActions. Necessary for the LastAction utility functions to work correctly.


clearLastActionsStack

public void clearLastActionsStack()
Clears the LastActionStackStore stack