Java Doc for ScriptAction.java in  » Web-Framework » struts-1.3.8 » org » apache » struts » scripting » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » struts 1.3.8 » org.apache.struts.scripting 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.struts.action.Action
      org.apache.struts.scripting.ScriptAction

ScriptAction
public class ScriptAction extends Action (Code)
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:
  1. Set struts.forwardName to the name of the forward
  2. Set struts.forward to the actual ActionForward object
A number of pre-defined variables are available to the script:
  • request - The HTTP request
  • response - The HTTP response
  • session - The session
  • application - The servlet context
  • struts - A grouping of all Struts-related objects
  • log - A logging instance
You can add your own variables by creating a BSFManagerFilter and configuring it in struts-scripting.properties:
  • struts-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.


To use other scripting engines other than BeanShell, create a file called 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.
This code was originally based off code from JPublish, but has since been almost completely rewritten.

Inner Class :class Script

Field Summary
final protected static  StringENGINE_BASE
     The base property for alternate BSF engines.
final protected static  StringFILTERS_BASE
     The base property for classes that put new variables in the context.
final protected static  LogLOG
     The logging instance.
final protected static  StringPROPS_PATH
     The default path to the properties file.


Method Summary
public  ActionForwardexecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
     Executes the script.
public  LocalegetLocale(HttpServletRequest req)
     Gets the locale.
public  booleanisCancelled(HttpServletRequest req)
     Checks to see if the request is cancelled.
public  booleanisTokenValid(HttpServletRequest req)
     Checks to see if the token is valid.
protected static  BSFManagerFilter[]loadFilters(Properties props)
     Loads and initializes the filters.
protected  ScriptloadScript(String name, ServletContext context)
     Loads the script from cache if possible.
protected  StringparseScriptName(String url, BSFManager manager)
     Parses the script name and puts any url parameters in the context.
public  voidresetToken(HttpServletRequest req)
     Resets the token.
public  voidsaveErrors(HttpServletRequest req, ActionErrors errs)
     Saves the errors to the request.
public  voidsaveMessages(HttpServletRequest req, ActionMessages mes)
     Saves the messages to the request.
public  voidsaveToken(HttpServletRequest req)
     Saves a token.
protected static  String[]split(String line, String delimiter)
     Splits a line with the given delimiter.

Field Detail
ENGINE_BASE
final protected static String ENGINE_BASE(Code)
The base property for alternate BSF engines.



FILTERS_BASE
final protected static String FILTERS_BASE(Code)
The base property for classes that put new variables in the context.



LOG
final protected static Log LOG(Code)
The logging instance.



PROPS_PATH
final protected static String PROPS_PATH(Code)
The default path to the properties file.





Method Detail
execute
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception(Code)
Executes the script.
Parameters:
  mapping - The action mapping
Parameters:
  form - The action form
Parameters:
  request - The request object
Parameters:
  response - The response object The action forward
exception:
  Exception - If something goes wrong



getLocale
public Locale getLocale(HttpServletRequest req)(Code)
Gets the locale.
Parameters:
  req - The request object The locale value



isCancelled
public boolean isCancelled(HttpServletRequest req)(Code)
Checks to see if the request is cancelled.
Parameters:
  req - The request object True if cancelled



isTokenValid
public boolean isTokenValid(HttpServletRequest req)(Code)
Checks to see if the token is valid.
Parameters:
  req - The request object True if valid



loadFilters
protected static BSFManagerFilter[] loadFilters(Properties props)(Code)
Loads and initializes the filters.
Parameters:
  props - The properties defining the filters An array of the loaded filters



loadScript
protected Script loadScript(String name, ServletContext context)(Code)
Loads the script from cache if possible. Reloads if the script has been recently modified.
Parameters:
  name - The name of the script
Parameters:
  context - The servlet context The script object



parseScriptName
protected String parseScriptName(String url, BSFManager manager) throws Exception(Code)
Parses the script name and puts any url parameters in the context.
Parameters:
  url - The script url consisting of a path and optionalparameters
Parameters:
  manager - The BSF manager to declare new parameters in The name of the script to execute
exception:
  Exception - If something goes wrong



resetToken
public void resetToken(HttpServletRequest req)(Code)
Resets the token.
Parameters:
  req - The request object



saveErrors
public void saveErrors(HttpServletRequest req, ActionErrors errs)(Code)
Saves the errors to the request.
Parameters:
  req - The request object
Parameters:
  errs - The action errors



saveMessages
public void saveMessages(HttpServletRequest req, ActionMessages mes)(Code)
Saves the messages to the request.
Parameters:
  req - The request object
Parameters:
  mes - The action messages



saveToken
public void saveToken(HttpServletRequest req)(Code)
Saves a token.
Parameters:
  req - The request object



split
protected static String[] split(String line, String delimiter)(Code)
Splits a line with the given delimiter.
Parameters:
  line - The line to split
Parameters:
  delimiter - The string to split with An array of substrings



Fields inherited from org.apache.struts.action.Action
protected transient ActionServlet servlet(Code)(Java Doc)

Methods inherited from org.apache.struts.action.Action
protected void addErrors(HttpServletRequest request, ActionMessages errors)(Code)(Java Doc)
protected void addMessages(HttpServletRequest request, ActionMessages messages)(Code)(Java Doc)
public ActionForward execute(ActionMapping mapping, ActionForm form, ServletRequest request, ServletResponse response) throws Exception(Code)(Java Doc)
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc)
protected String generateToken(HttpServletRequest request)(Code)(Java Doc)
protected ActionMessages getErrors(HttpServletRequest request)(Code)(Java Doc)
protected Locale getLocale(HttpServletRequest request)(Code)(Java Doc)
protected ActionMessages getMessages(HttpServletRequest request)(Code)(Java Doc)
protected MessageResources getResources(HttpServletRequest request)(Code)(Java Doc)
protected MessageResources getResources(HttpServletRequest request, String key)(Code)(Java Doc)
public ActionServlet getServlet()(Code)(Java Doc)
protected boolean isCancelled(HttpServletRequest request)(Code)(Java Doc)
protected boolean isTokenValid(HttpServletRequest request)(Code)(Java Doc)
protected boolean isTokenValid(HttpServletRequest request, boolean reset)(Code)(Java Doc)
protected void resetToken(HttpServletRequest request)(Code)(Java Doc)
protected void saveErrors(HttpServletRequest request, ActionMessages errors)(Code)(Java Doc)
protected void saveErrors(HttpSession session, ActionMessages errors)(Code)(Java Doc)
protected void saveMessages(HttpServletRequest request, ActionMessages messages)(Code)(Java Doc)
protected void saveMessages(HttpSession session, ActionMessages messages)(Code)(Java Doc)
protected void saveToken(HttpServletRequest request)(Code)(Java Doc)
protected void setLocale(HttpServletRequest request, Locale locale)(Code)(Java Doc)
public void setServlet(ActionServlet servlet)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.