8.7 Nested Tags


The Struts custom tag libraries provide a great deal of power and flexibility to the developer. The freedom to access properties of a bean at any level using nested properties is very powerful.

There are some restrictions in how this technique can be deployed, however. When attempting to nest one tag inside another, the inside tag has certain dependencies on the outside tag that may make it cumbersome or impossible to cleanly render the dynamic data. There are workarounds, but these usually involve using scriptlets with Java within the JSP page. "Nested" tags were created to solve this problem and to enrich the Struts tag libraries.

The Nested tag library was created by Arron Bates to make it easier to nest Struts tags inside one another and to match the ability of the model layer to nest beans inside one another. The nested tags have become so popular that they have been added to the core libraries.

Nested tags parallel the current tags supported by the Struts framework. For example, there are HTML nested tags, Logic nested tags, and Bean nested tags. There is no need for nested Template tags, so those don't exist. The major difference is that nesting is better supported in the nested versions.

The tags within the Nested tag library are used in the same way that the non-nested versions are. Minor differences exist to allow for tags to know when they are nested within one another and therefore can access properties of the parent tag. Other than these small differences, they are very similar.

You can find more information on the nested tags in the Struts API documents. Tutorials and more information on the nested tags are available at http://www.keyboardmonkey.com/struts/index.html.



Programming Jakarta Struts
Programming Jakarta Struts, 2nd Edition
ISBN: 0596006519
EAN: 2147483647
Year: 2003
Pages: 180

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net