J2ee hosting - Managing and Customizing OpenCms 6 A practical guide
Managing and Customizing OpenCms 6 A practical guide to creating and managing your own website with this proven Java/JSP-based content management system Matt Butcher BIRMINGHAM - MUMBAI
fontSize = size; } public String getFontSize() { return fontSize; } public void setColor( String col ) { color = col ; } public String getColor() { return color ; } public int doAfterBody() throws JspException { BodyContent tagBody = getBodyContent() ; String tagBodyAsString = tagBody.getString() ; try { JspWriter out = tagBody.getEnclosingWriter() ; if ( getReverse() ) tagBodyAsString = ((new StringBuffer(tagBodyAsString)).reverse() ).toString() ; out.print( “” + tagBodyAsString + “” ) ; } catch (IOException ex) { throw new JspTagException(ex.toString()); } return SKIP_BODY ; } } The get and set methods for the attributes are as before nothing new there. The new code constructs are in italic. Let s take a look. The first new construct is found on the class statement: public class formatLine extends BodyTagSupport Classes that change the tag body must implement the BodyTag interface or extend the convenience class BodyTagSupport. The BodyTag interface extends the tag interface so you can continue to code doStartTag and doEndTag methods if you need to. In this example, you do not need to take action at the start or the end of the tag, hence, you did not code the doStartTag and doEndTag methods. For the most part, you would code doStartTag and doEndTag the same way in classes that extend BodyTagSupport as you would in classes that extend TagSupport. However, doStartTag should return the constant EVAL_BODY_TAG, a constant not found in the tag interface. The name of the method that processes the tag s body is doAfterBody. More accurately, the doAfterBody method is invoked after the JSP container evaluates any statements or expressions. If you want to perform processing on the tag body before any JSP statements are evaluated, code a doInitBody method. Perhaps a table showing the order of method invocation is in order. Table 7-3 illustrates the order of method invocation. Table 7-3: Order of Method Invocation