JavaServer Page

February 5, 2007

The Show tag BPoints to the object whose

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

CHAPTER 8 Using JavaBeans with tags Listing 8.5 Source code for the ShowTag handler class package book.reflection; import book.util.LocalStrings; import javax.servlet.jsp.JspException; public class ShowTag extends ReflectionTag { static LocalStrings ls = LocalStrings.getLocalStrings(ShowTag.class); protected void processObject(Object v) b throws JspException { try { writeHtml(pageContext.getOut(), v.toString()); } catch(java.io.IOException ioe) { // User probably disconnected … // Log and throw an exception } } } B Overrides processObject() to print the property value. TagExraInfo for ShowTag The last portion of code left unseen is the TagExtraInfo that we shall attach to the ShowTag. In fact, since ShowTag does not add any new attribute or syntactic constraints, we can actually take a TagExtraInfo, as developed for ReflectionTag, and use it for ShowTag (listing 8.6). Listing 8.6 Source code for the ReflectionTagExtraInfo class package book.reflection; import javax.servlet.jsp.tagext.TagData; import javax.servlet.jsp.tagext.TagExtraInfo; import javax.servlet.jsp.tagext.VariableInfo; public class ReflectionTagExtraInfo extends TagExtraInfo { public boolean isValid(TagData data) { Object o = data.getAttribute(”object”); if((o != null) && (o != TagData.REQUEST_TIME_VALUE)) { b return false; }

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