net.sf.jolene.struts
Class DomletAction

java.lang.Object
  extended by org.apache.struts.action.Action
      extended by org.apache.struts.actions.BaseAction
          extended by org.apache.struts.actions.DispatchAction
              extended by net.sf.jolene.struts.DomletAction

public class DomletAction
extends org.apache.struts.actions.DispatchAction

Default action servlet for jolene. Implements a modified DispatchAction which can match request uri string to the method name of the action class. The primary purpose is to associate a uri to a document object. There are several ways to do this see the method descriptions.

Since:
Sep 23, 2006 5:40:15 PM
Author:
Dan Howard

Constructor Summary
DomletAction()
           
 
Method Summary
 org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Performs a basic dispatch of the request looking for the parameter from the struts mapping or by using the struts action name itself.
 Document getDocument(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
          Retrives a document object based on the mapping input attribute and attaches it to the proper scope.
 Document getDocument(org.apache.struts.action.ActionMapping mapping, java.lang.String forward, javax.servlet.http.HttpServletRequest request)
          Retrives a document object based on the specified forward.
 
Methods inherited from class org.apache.struts.action.Action
execute, getServlet, setServlet
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomletAction

public DomletAction()
Method Detail

execute

public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping,
                                                      org.apache.struts.action.ActionForm form,
                                                      javax.servlet.http.HttpServletRequest request,
                                                      javax.servlet.http.HttpServletResponse response)
                                               throws java.lang.Exception
Performs a basic dispatch of the request looking for the parameter from the struts mapping or by using the struts action name itself.

Overrides:
execute in class org.apache.struts.actions.DispatchAction
Parameters:
mapping - ActionMapping
form - ActionForm
request - HttpServletRequest
response - HttpServletResponse
Returns:
ActionForward
Throws:
java.lang.Exception

getDocument

public Document getDocument(org.apache.struts.action.ActionMapping mapping,
                            javax.servlet.http.HttpServletRequest request)
                     throws java.io.IOException
Retrives a document object based on the mapping input attribute and attaches it to the proper scope. The reason for this method is to allow a default document to be associated with an action since actions can have many forwards.

For example, calling this method would get the document from the /domlet/login.html uri.

 <action
 path="/login"
 type="domlet.kbsample.web.actions.LoginAction"
 name="LoginForm"
 scope="session"
 validate="false"
 input="/domlet/login.html">
  
 <forward name="success" path="/browse.do"/>
 <forward name="fail" path="/domlet/error.html"/>
 <forward name="login" path="/domlet/login.html"/>
 </action>
 

Parameters:
mapping - ActionMapping
request - HttpServletRequest
Returns:
Document or null if the uri for input mapping is undefined in struts-config.xml
Throws:
java.io.IOException - if an IOException occurs

getDocument

public Document getDocument(org.apache.struts.action.ActionMapping mapping,
                            java.lang.String forward,
                            javax.servlet.http.HttpServletRequest request)
                     throws java.io.IOException
Retrives a document object based on the specified forward.

For example, using the following in struts-config.xml:

 <action
 path="/login"
 type="domlet.kbsample.web.actions.LoginAction"
 name="LoginForm"
 scope="session"
 validate="false"
 input="/domlet/login.html">
  
 <forward name="success" path="/browse.do"/>
 <forward name="fail" path="/domlet/error.html"/>
 <forward name="login" path="/domlet/login.html"/>
 </action>
 

getDocument(mapping, "fail", request); Returns document from /domlet/error.html
getDocument(mapping, "login", request); Returns document from /domlet/login.html

Parameters:
mapping - ActionMapping
forward - forward string
request - HttpServletRequest
Returns:
Document or null if the forward cannot be found in struts-config.xml
Throws:
java.io.IOException - if an IOException occurs