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/StrutsManualActionWebComponent

------------------------------------------------------------------------------
   * one or more JSP files that represent one or more component subviews;
   * an optional form bean that holds input/output data.
  
- Struts web component uses Action class to process incoming events, and 
employs JSP technology to render a view.
+ Struts web component uses Action class to process incoming events, and 
employs JSP technology to render a view. The lifecycle of the components is 
fully managed by Struts. The components can be used in any application that 
employs JSP as rendering technology, not just in Struts-based application.
+ 
+ == Dual-Mode Capability ==
+ 
+ Struts utilizes two request processing concepts when dealing with web 
components:
+ 
+  * Traditional synchronous HTTP request/response cycle (Non-Ajax mode), and
+  * Asynchronous in-place update for Javascript-enabled browsers with 
XMLHTTPRequest support (Ajax mode).
+ 
+ In synchronous mode the browser submits input data to a fragment, the 
fragment updates its state if necessary, then the composite page is 
automatically  reloaded by redirecting browser to the original page location. A 
request that follows pulls up web components and they render themselves.
+ 
+ In Ajax mode browser submits input data using an asynchronous request. Struts 
renders a view directly in response to this request, no page reloading is 
needed. HTML markup, returned by a component, is inserted into the composite 
page without full page refresh.
+ 
+ Pages composed from Struts components look and behave uniformly whether they 
run in Ajax mode or not. The dual-mode functionality of Struts web components 
is invaluable for environments where !JavaScript is not allowed or in browsers 
that do not support the {{{XMLHTTPRequest}}} object, like some mobile browsers.
  
  == Use Case: Login Component ==
  
@@ -27, +40 @@

  
  inline:javanet_loggedin.gif
  
- In a regular web application the login/logout module would be responsible to 
navigate to a proper location after processing user input. In the example above 
a user must be transferred to the same location that he was browsing before 
logging in. Therefore login/logout module should be tightly integrated with its 
parent page, or the parent page must process login/logout events itself.
+ In a regular web application the login/logout module would be responsible for 
navigation to a proper location after processing user input. In the example 
above a user must be transferred to the same location that he was browsing 
before logging in. Therefore login/logout module should be tightly integrated 
with its parent page, or the parent page must process login/logout events 
itself.
  
- == Struts Web Components Are Independent ==
- 
- With Struts you can build truly independent web components that bear no 
knowledge about a page they are included into. Furthermore, a composite page 
does not need to know about components contained in it. A web component should 
mean its own business, that is handle its input and render its markup. Struts 
takes care about the rest. These boring tasks include:
+ With Struts you can build truly independent web components that bear no 
knowledge about a page they are included into. Furthermore, a composite page 
does not need to know about components contained in it. A web component should 
mean its own business, that is, handling its input and rendering its markup. 
Struts takes care about the rest. These boring tasks include:
  
   * Calculating the location of a composite page (used to automatically reload 
a composite page).
   * Calculating the location of a component (can be used as submission target).
   * Save page/component locations between requests.
   * Checking whether a browser supports Javascript and if it does, using Ajax 
to replace component markup in place instead of reloading a whole composite 
page.
  
- == Building Struts Web Components ==
+ == Building A Simple Struts Web Component ==
  
- See the links below for further reading:
+ This guide explains Struts component functionality by building a simple login 
component. The Login Component has two states: "Logged In" and "Not Logged In", 
two corresponding views: "loggedin" and "notloggedin", and two input events: 
"login" and "logout".
  
-  * [:StrutsManualActionWebComponentSync:Building synchronous Struts web 
component]
-  * [:StrutsManualActionWebComponentAsync:Building dual-mode Struts web 
component]
+ If a user has not logged in yet, the Login Component stays at "Not Logged In" 
state. The "notloggedin" view displays login form with "username" and 
"password" fields and "Log In" button. The button submits login form, sending 
"login" event to the component.
+       
+ When a user logs in, the Login Component switches to "Logged In" state. The 
corresponding "loggedin" view displays logout form that shows user name and 
"Log Out" button. The button submits logout form, sending "logout" event to the 
component.
  
+ We will build a synchronous component first, then we will convert it into a 
true dual-mode component.
+ 
+ Next: [:StrutsManualActionWebComponentSync:Building synchronous login 
component]
+ 

Reply via email to