JavaServer Page

February 5, 2007

The Show tag BPoints to the object whose

Filed under: JSP Tag Libraries — webmaster @ 2:33 am

The Show tag BPoints to the object whose property we want to get We can have either the object itself or its name and scope (optional). There are two ways to specify the object used by the tag: one way is to set the object as a runtime expression value, the other is to specify the name and the scope. These two object specification methods are mutually exclusive, and our TagExtraInfo implementation should take care of this. But we are getting ahead of ourselves. CgRefers to the property name and the index (optional) in this property The property value is specified by two attributes: the property name and an index into the property. The index is not mandatory and the tag can handle cases in which the index is not specified. The index, you ll recall, may be a string or an integer; but how can we specify two different types using a single attribute? We cheat! We specify the integer within a string, but prefix its value with a # so that the tag knows that the value represents an integer. Why are we giving an advantage to the string? Because strings are far more useful as an index when we are creating web pages. In most cases, we will index our properties using a string, as it was felt that string indexing should be easily done. DdoStartTag() fetches the property value and lets the tag process it using process- Object(). EFetches the object If the object was configured as a runtime value, either use it, or get a reference to it using the name and the scope. FAs soon as we receive the object, fetches the property value. GA # prefix denotes an integer Translates the string to an integer. HGets the propery value using the beans utility class. IprocessObject() is a method that an extending class can overide to process the value of our object property As previously stated, ReflectionTag is an abstract class whose job is to provide access through reflection to properties in the JSP scripting objects. In this spirit, we defined an empty method named process- Object() that can be overridden by an extending class, whose only goal is to manipulate the property value. Implementing processObject() is not mandatory and, for many cases, it may be better to override doStartTag() and use the method getPointed() directly; however, for the purpose of our new ShowTag (listing 8.5), overriding processObject() is enough. ShowTag The ShowTag handler is the handler for the tag to be used by the JSP author, and inherits from ReflectionTag to make use of its introspection work. This tag then retrieves the value for a property and prints it to the user.

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

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by Java Web Hosting