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 ------------------------------------------------------------------------------ == Use Case: Home Page With Login Component == - Consider a website that has a login form located in a highly visible part of the website. The login form allows a user to log in and thus to gain access to protected area of the website. A non-logged-in user must be presented with login form, a logged-in user should be able to log out. The screenshot from www.java.net website illustrates this use case. + Consider a website with a login form that authorizes access to member-only area of the website. A non-logged-in user must be presented with login form, a logged-in user should be able to log out. The screenshot from www.java.net website illustrates this use case. - inline:login-component-sm.gif + A casual visitor sees a login form: + + inline:javanet_notloggedin.gif + + After a visitor logs in, he is presented with exactly the same page. The only difference is that login form is replaced with logout form: + + inline:javanet_loggedin.gif + + In a regular web application it is responsibility of login/logout module to navigate to a proper location after processing user input. In the above case 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. Another solution is that a parent page itself must process login/logout events. + + == Struts Web Components Are Independent == + + With Struts you can build web component that bears no knowledge about page it is included into. Furthermore, a composite page itself does not need to know what components does it contain. A web component must handle its own input and render its own markup. Struts takes care about everything else. This boring tasks include: + + * Calculating the location of a composite page, used to reload a composite page. + * Calculating the location of a component, can be used as submit 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. + + When you develop a Struts Web Component you have to deal only with component's input and component's output. You do not need to care how exactly the composite page will be updated. == Building Struts Web Components ==