Generalized iterating tags protected void clearProperties() { elements

Generalized iterating tags protected void clearProperties() { elements = null; c super.clearProperties(); } } class IteratorIterationSupport implements IterationSupport { d Iterator i = null; IteratorIterationSupport(Iterator i) { this.i = i; } public boolean hasNext() throws JspException { return i.hasNext(); } public Object getNext() throws JspException { return i.next(); } } b Parsing the list specification string and making an IterationSupport out of it. C Clearing the additional tag property. D Implementing an IterationSupport class that uses a Java Iterator object. The new ForeachTag has most of its code implementing its tag-specific functionality, that is, dealing with an Iterator of Strings. Also of note in our implementation is the additional IteratorIterationSupport class we created, which is simply an implementation of the generic IterationSupport that works on the java.util.Iterator interface. We can imagine a similar class that works on Arrays and even another for Enumerations (or perhaps one that handles all?). The IteratorIterationSupport class is not, of course, unique to ForeachTag and we will be able to reuse it many times in other specialized tags. We now have a way to easily create iteration tags that iterate on all sorts of objects. We ll flex the power of this infrastructure in the next section in creating a tag that is capable of iterating on just about anything.

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services

Bookmark the permalink.

Comments are closed.