【正文】
s incorporation within the JSP STL standard ensures even wider distribution and availability of the Struts and Tiles functionality, meaning portability of skills for developers moving between projects and easy access to skilled talent for panies looking to develop Web applications. What can you take away from this article?After reading this article, the following key points should stay with you: MVC is a good architecture for developing robust Web software. A pageoriented architecture is simple, but fails as an application grows in size and scope. MVC is a proven model for larger applications. Struts and Tiles provide a solid base for plex applications. Struts and Tiles adhere to the MVC paradigm and allow developers to create an application that can manageably grow with the needs of the business. Struts and Tiles enjoy strong industry support, as well as popularity and momentum among developers. This ensures broad adoption and protects the investment of time and money made by developers and panies. With Struts and Tiles, you39。s included with the Struts bundle. Another useful feature of the Struts and Tiles package is integration with containermanaged security. Many of you are using application servers such as IBM WebSphere or JBoss. These servers facilitate authentication and authorization by handling many of the routine tasks involved in security, freeing you from having to code them. Struts allows you to conditionally display different bits of bean data to different users based on user role, which is determined by automatically querying the container. Similarly, the Tiles framework allows you to conditionally display different view ponents to different users based on user role, again determined by automatically querying the container. I use these features in my own applications to display different menus to administrators, regular users, or guests. Finally, I have not touched on internationalization in my examples, but it is a real concern for people building large applications that will ultimately be published in multiple languages. Struts lets you create message resource properties files that specify text for labels, titles, and other output. If you have populated a message resource properties file with all outputs in several different languages, you can change all widgets and hardcoded text to the appropriate language with a simple change of the language setting, even on the fly. Future directions Where do Struts and Tiles go from here? Two changes on the horizon promise to 8 make Struts and Tiles even more useful. The first is a workflow management system. You have likely dealt with many multistep business processes。t like it (though the name you use must match targets specified in the file). The names should match the path attribute in the forward name=x path=y/ tags in . The names should also match the input attribute in the action ... input= .../ tags in . The extends attribute in the definition name=x extends=y/ tag is where the magic that delivers agility to user interface development happens. By specifying a master layout and extending it, you have the flexibility of not only changing mon elements like topBanner, topMenu, panel1, panel2, and other ponents, but also the freedom to put different elements on the page and change where they are located. For instance, you could add panel4, a tile to display the local weather, below panel2 on the left side of the page. As long as the weather code does not require any input from the user or interaction with other ponents on the page, you could make the addition of panel4 without any changes whatsoever to the application business logic, or even any changes to JSP pages other than . 7 More plex uses of Struts and Tiles Space does not permit me to discuss other useful aspects of the Struts and Tiles package in depth, but I do want to touch on them briefly so you can get a sense of what Struts and Tiles can do. Perhaps these can be the topics of future articles if there is sufficient demand. You will note that in both the examples in this article, I coded some basic validation of the first name, last name, favorite color, and birthdate. Simple validation of the sort I employed could actually be performed by Struts using its format validation, thus saving time spent coding Java statements. It is possible, for instance, to check for empty strings, to check that a string matches a date, or to check for a match with some other regular expression. You will find it very handy to use format validation as a firstlevel check with which your program can eliminate obvious errors before checking for adherence to more plex business logic rules. Struts provides a validator package that is configured via a descriptor in the WEBINF directory. I have not included the validator package in the two examples。s properties in the file, and presto! The bean is automatically created without need for a separate file housing a Java class. The dynamic form beans are treated like Hashtable objects with strongly typed objects for values. As for action mappings, the ability to specify a tile as a target was a pletely logical addition once the decision was made to incorporate the Tiles library into the Struts distribution. You can see the tile targets ( and ) in the action mapping for the profile form. The tiles are specified in the input attribute and the path attribute. Note that the ability to specify a tile target remedies the problem of changing filenames and locations 6 mentioned in my analysis of the pagecentric model: tile targets are virtual or logical names rather than physical names. Tiles are specified in definition/ tags. You can name the definitions anything you want, and the name attribute