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 ------------------------------------------------------------------------------ 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". - - inline:basic_action_asp.gif - '''Example''' - Consider the Action that performs a search. The author of this code should not bother about specifics of presentation of the search results. His only job is to say "what happened" after the search took place. + Consider the Action that performs a search. The author of this code should not bother neither about how exactly the search criteria is obtained, nor about how the search results are presented. His only job is to say "what happened" after the search took place. Logically, there are three interesting outcomes: * No results were found => outcome "none". @@ -42, +38 @@ * 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. + + == Using Action To Display A Web Page == + + You might be wondering now, how does an Action class obtain input and render output in a real-life application. Let us start with output, like creating a read-only page that prints out current time. + + JSP is a default view technology used when developing with Struts. JSP creates dynamic web content by reading information from various Java beans floating around in page, request, session or application scope. In a Model 1 application these beans are put into scope by the code that resides in JSP page itself. + + A standard practice to display a dynamic page in a Struts application is to use Action class "in front" of a JSP page. Action class creates needed beans, puts them in an appropriate context, and forwards control to a JSP page that reads information from these beans and displays it. Action class has access to all contexts available from JSP page except PageContext. In a simple case such ''setup action'' does not have to accept parameters, its only purpose is to prepare output data for rendering. + + The following picture illustrates a "render page" use case implemented with Struts and ASP.NET. + + inline:basic_action_asp.gif == Action And Web Forms ==