Dear Wiki user, You have subscribed to a wiki page or wiki category on "Struts Wiki" for change notification.
The following page has been changed by MichaelJouravlev: http://wiki.apache.org/struts/StrutsManualActionClasses ------------------------------------------------------------------------------ - '''Attention: this page describes functionality that is not yet available in GA Struts release! Work in progress!''' - - == Action Classes == - The goal of an Action class is to process a request and return an ActionForward object. Action class can either implement a ''stateless service'' like "search", or can manage a logical ''web resource'' like "Customer". !ActionForward object identifies where control should be transferred to provide the appropriate response, and usually designates either another Action (see [:ActionChaining:action chaining]) or a presentation page. Struts is agnostic to presentation technology, so response can be generated using JSP file, Tile definition, Velocity template, XSLT stylesheet or other rendering engine. !ActionForward object represents a logical outcome of processing a request. By not defining a specific menu choice or a page URL it is possible to separate state of a resource from its visual representation. + + Action class handles all incoming requests with one callback method, {{{execute()}}}. Two overloaded versions of this method are available. Choosing one or another depends on your servlet environment: + + {{{public ActionForward execute(ActionMapping mapping, + ActionForm form, + ServletRequest request, + ServletResponse response) + throws Exception; + + public ActionForward execute(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) + throws Exception;}}} + + Since the majority of teams using the framework are focused on building web applications, most projects will only use the "!HttpServletRequest" version. A non-HTTP execute() method has been provided for applications that are not specifically geared towards the HTTP protocol. The following picture illustrates a simple "render page" use case implemented with Struts and ASP.NET. In Struts the requests means something like "Process request data and transfer control to a JSP page that corresponds to result of the processing". In ASP.NET the request simply means "Display the page". @@ -30, +42 @@ * If there's more than one response, go to the list page (as per the previous behavior). Note that the code of the search action is not affected by this decision. In Struts the outcomes returned by an action are much more stable than the presentation locations. On contrary, in ASP.NET the outcome is simply the page that was requested. - - Action class handles all incoming requests with one callback method, {{{execute()}}}. Two overloaded versions of this method are available. Choosing one or another depends on your servlet environment: - - {{{public ActionForward execute(ActionMapping mapping, - ActionForm form, - ServletRequest request, - ServletResponse response) - throws Exception; - - public ActionForward execute(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) - throws Exception;}}} - - Since the majority of teams using the framework are focused on building web applications, most projects will only use the "!HttpServletRequest" version. A non-HTTP execute() method has been provided for applications that are not specifically geared towards the HTTP protocol. == Action And Web Forms == @@ -119, +115 @@ inline:action_component_generic.gif - Struts 1.4 allows to create web components using Struts Action class for event processing, JSP for presentation and an optional Javascript helper for in-place update in Ajax mode. + Struts 1.4 will allow creating web components using Struts Action class for event processing, JSP for presentation and an optional Javascript helper for in-place update in Ajax mode. See [:StrutsManualActionWebComponent:Developing Web Components With Struts] on using web component manager and code samples.