|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.struts.action.Action org.apache.struts.scripting.ScriptAction
public class ScriptAction
This Action uses scripts to perform its action. The scripting framework is
Apache's Bean Scripting Framework which allows the scripts to be written
many of the popular scripting languages including JavaScript, Perl, Python,
and even VBA.
To determine what script will be executed, the "parameter" attribute of the
action mapping should contain the name of the script relative to the web
application root directory (i.e. http://server/app).
Before the script completes, the next ActionForward needs to be specified.
This can be done one of two ways:
struts.forwardName
to the name of the forwardstruts.forward
to the actual ActionForward object
request
- The HTTP requestresponse
- The HTTP responsesession
- The sessionapplication
- The servlet contextstruts
- A grouping of all Struts-related objectslog
- A logging instancestruts-scripting.filters.FILTER_NAME.class=FILTER_CLASS
- The class implementing BSFManagerFilter where FILTER_NAME is the name
you are calling the filter.
struts-scripting.filters.FILTER_NAME.PROPERTY_NAME=PROPERTY_VALUE
- A property to be used by the filter.struts-scripting.properties
and add two properties for each
engine:
struts-scripting.engine.ENGINE_NAME.class
- The class of
the BSF engine where ENGINE_NAME is the name you are calling the engine.
struts-scripting.engine.ENGINE_NAME.extensions
- A
comma-delimited list of file extensions that will be used to identify the
engine to use to execute the script.
Field Summary | |
---|---|
protected static String |
ENGINE_BASE
The base property for alternate BSF engines. |
protected static String |
FILTERS_BASE
The base property for classes that put new variables in the context. |
protected static Log |
LOG
The logging instance. |
protected static String |
PROPS_PATH
The default path to the properties file. |
Fields inherited from class org.apache.struts.action.Action |
---|
servlet |
Constructor Summary | |
---|---|
ScriptAction()
|
Method Summary | |
---|---|
ActionForward |
execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
Executes the script. |
Locale |
getLocale(HttpServletRequest req)
Gets the locale. |
boolean |
isCancelled(HttpServletRequest req)
Checks to see if the request is cancelled. |
boolean |
isTokenValid(HttpServletRequest req)
Checks to see if the token is valid. |
protected static BSFManagerFilter[] |
loadFilters(Properties props)
Loads and initializes the filters. |
protected org.apache.struts.scripting.ScriptAction.Script |
loadScript(String name,
ServletContext context)
Loads the script from cache if possible. |
protected String |
parseScriptName(String url,
org.apache.bsf.BSFManager manager)
Parses the script name and puts any url parameters in the context. |
void |
resetToken(HttpServletRequest req)
Resets the token. |
void |
saveErrors(HttpServletRequest req,
ActionErrors errs)
Deprecated. Use saveErrors(HttpServletRequest, ActionMessages) instead. This will be removed after Struts 1.2. |
void |
saveMessages(HttpServletRequest req,
ActionMessages mes)
Saves the messages to the request. |
void |
saveToken(HttpServletRequest req)
Saves a token. |
protected static String[] |
split(String line,
String delimiter)
Splits a line with the given delimiter. |
Methods inherited from class org.apache.struts.action.Action |
---|
addErrors, addMessages, execute, generateToken, getErrors, getMessages, getResources, getResources, getServlet, isTokenValid, saveErrors, saveErrors, saveMessages, setLocale, setServlet |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Log LOG
protected static final String PROPS_PATH
protected static final String ENGINE_BASE
protected static final String FILTERS_BASE
Constructor Detail |
---|
public ScriptAction()
Method Detail |
---|
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
execute
in class Action
mapping
- The action mappingform
- The action formrequest
- The request objectresponse
- The response object
Exception
- If something goes wrongprotected String parseScriptName(String url, org.apache.bsf.BSFManager manager) throws Exception
url
- The script url consisting of a path and optional
parametersmanager
- The BSF manager to declare new parameters in
Exception
- If something goes wrongprotected org.apache.struts.scripting.ScriptAction.Script loadScript(String name, ServletContext context)
name
- The name of the scriptcontext
- The servlet context
protected static BSFManagerFilter[] loadFilters(Properties props)
props
- The properties defining the filters
protected static String[] split(String line, String delimiter)
line
- The line to splitdelimiter
- The string to split with
public void saveToken(HttpServletRequest req)
saveToken
in class Action
req
- The request objectpublic boolean isCancelled(HttpServletRequest req)
isCancelled
in class Action
req
- The request object
public boolean isTokenValid(HttpServletRequest req)
isTokenValid
in class Action
req
- The request object
public void resetToken(HttpServletRequest req)
resetToken
in class Action
req
- The request objectpublic Locale getLocale(HttpServletRequest req)
getLocale
in class Action
req
- The request object
public void saveMessages(HttpServletRequest req, ActionMessages mes)
saveMessages
in class Action
req
- The request objectmes
- The action messagespublic void saveErrors(HttpServletRequest req, ActionErrors errs)
req
- The request objecterrs
- The action errors
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |