the executeAction( )method. Each subclass implements the abstract (Web design software)

the executeAction( )method. Each subclass implements the abstract executeAction( ) method and has the UserContainer passed in, instantiated, and guaranteed not to be null. This is only a trivial example of what you can do. Any behavior that all actions need to perform is a candidate for being implemented in the Action superclass, so that when the time comes to modify the implementation, only the behavior in the superclass needs to change. 9.4 Extending View Components There generally is less reason or need to extend components located within the view layer than there is to extend components in the controller layer. Typically, views are written exclusively for an application; for example, it’s unlikely that a JSP page written for one application will be used within a different application. This is not always the case, but differences between look-and-feel and content make such reuse improbable. The one area within the Struts view layer where extensions often are created, however, is in the JSP tag libraries. 9.4.1 Extending Struts Custom Tags The custom tags provided by the Struts framework can be reused across applications and application domains. Therefore, it makes sense that customization and extensions are more likely with these components than with JSP pages. Because the tag handlers are regular Java classes, specialization is achieved through subclassing. Although you can extend any tag, the HTML tag library is the one that you’ll most likely need to customize (mainly because the custom tags within this library have the greatest impact on the view content). Regardless of which tags you extend, you’ll need to create your own tag library to hold your tag extensions. You could modify the Struts tag libraries and include your new tag class, but that would make upgrading to newer versions of the Struts framework much harder. You’re better off creating your own tag library that contains just your application’s tags. Once you’ve created a .tld file for your extensions and registered it with the web application deployment descriptor, you are free to use your tags just as you would any others. 9.5 Extending Model Components Because the Struts framework doesn’t provide a great deal of components for the model layer, extensions to these components are better discussed in other Java programming books. However, there are two classes that might be placed into the category of extensible model components. They aren’t the best representations of what a model component is, but they are responsible for holding model state. 9.5.1 The UserContainer and ApplicationContainer Classes I’ve mentioned the UserContainerand ApplicationContainer classes in previous chapters without defining exactly what they are. These two classes are not part of the Struts framework I created them as part of the example Storefront application. The purpose of these classes is to store user and application-specific information in instances of these classes, rather than in the HttpSessionand ServletContext objects, respectively.
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

Leave a Reply