Saturday, February 27, 2010

Struts2 course chapter 19: Decorating Struts2 with Tiles

In this presentation the topic of decorating Struts2 websites with Apache Tiles is covered. Apache Tiles is a framework built to simplify the development of web application through the use of templates. With Tiles authors can define page fragments which can be assembled into a complete page at runtime. These fragments, called tiles, can be used as simple includes in order to reduce the duplication of common page elements or embedded within other tiles to develop a series of reusable templates. These templates allow the development of a consistent look and feel for an entire application. The integration between Apcahe Tiles and Struts can be difficult and in the slide the details of the configuration are explained. In addition, a working example is presented.
Struts2 course chapter 19: Decorating Struts2 with Tiles


Download the eclipse project with the example of the slide from the following location:
Reblog this post [with Zemanta]
Read more »

Friday, February 26, 2010

Struts2 course chapter 18: Decorating Struts2 with SiteMesh

In this presentation the topic of decorating Struts2 websites with SiteMesh will be covered. SiteMesh is a framework for web-page layout and decoration as well as for web-application integration. This framework helps to the creation of large sites consisting of many pages for which a consistent look/feel, navigation and layout scheme is required. The integration of SiteMesh and Struts2 can be tricky so all the deails of the configuration will be covered.
Struts2 course chapter 18: Decorating Struts2 with SiteMesh


Download the eclipse projects with the examples of the slide from the following locations:
Read more »

Thursday, January 7, 2010

'Struts2 Course chapter 17: The Execute and Wait Interceptor

The Execute And Wait interceptor is useful for running time consuming process in the background while showing the user some feedback with a progress meter. This also prevents the HTTP request from timing out when the action takes more than 5 or 10 minutes.

This interceptor works on a per-session basis. That means that the same action name cannot be run more than once at a time in a given session. On the initial request or any subsequent requests (before the action has completed), the wait result will be returned.

The wait result is responsible for issuing a subsequent request back to the action, giving the effect of a self-updating progress meter.

Using this interceptor is pretty easy but this interceptor is not part of the default stack. Since it's not part of the default stack, actions that need this interceptor must declare it and because of the nature of this interceptor, it must be the last interceptor in the stack.

If no "wait" result is found, Struts will automatically generate a wait result on the fly.

This is the topic of the next slides.

Struts2 Course chapter 17: The Execute and Wait Interceptor

Download the eclipse ready example projects:

Read more »

Struts2 Course chapter 16: Preventing Double Submits

Double form submits are the nightmare of web application developers. They normally happen by accident or lack of feedback when users wait for a long time process of a form submission.

Double submits may have fatal consequences. For instance, when submitting an online payment in which a credit card will be charged.

Users may click the submit button for a second time if the server's response time is too slow. This may result in his/her credit card being charged twice.

Other less critical examples include forms that add a new product and doubly submitting these forms will cause a product to be added twice causing inconsistencies in the database and inventory.

Fortunately Struts has built-in support for preventing double submits. It employs a technique that you can also find in other web application development technologies.

This technique involves storing a unique token in the server and inserting a copy of the token into a form. When the form is submitted, this token is also sent to the server.

The server application will compare the token with its own copy for the current user. If they match, form submission is considered valid and the token is reset. Subsequent (accidental) submits of the same form will fail because the token on the server have been reset.

This is the topic of the next slides.

Struts2 Course chapter 16: Preventing Double Submits

Download the eclipse ready example projects:

Read more »

Monday, December 28, 2009

Struts2 course chapter 15: Custom Result Types

Struts2 comes with a dozen or more result types, for example: Dispatcher Result, Redirect Result, Chain Result, XSL Result, etc. These results cover the majority of our necesities.

However, what happen if I need a new type of result type? for ejample an Json reult type to deal with Ajax clients? or a Image result?. In these cases, we need to imlement our own results and in the next slides we will show how to make our own custom interceptors.

Struts2 course chapter 15: Custom Result Types


Download the code example (yes is file 16):

Read more »

Struts2 Course chapter 14: Custom Interceptors

Struts2 comes with a rich set of default interceptors. For example, there is the input validation that is handled by the Validation interceptor. Unplug this interceptor and validation will stop working.

File upload is so easy beacuse of another interceptor, the File Upload interceptor. Some interceptors may prevent from the execution of an action if certain conditions are not met. For instance, the Validation interceptor keeps an action from firing if an error occurs during the validation of that action.

For most applications, the default interceptors are sufficient. However, sometimes you will need to create your own interceptor. This chapter explains how to create custom interceptors.

Struts2 Course chapter 14: Custom Interceptors


Download the code example (yes is file 15)::

Custom Interceptors in Struts2
Read more »