KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > module > sitemesh > taglib > decorator > TitleTag


1 /*
2  * Title: TitleTag
3  * Description:
4  *
5  * This software is published under the terms of the OpenSymphony Software
6  * License version 1.1, of which a copy has been included with this
7  * distribution in the LICENSE.txt file.
8  */

9
10 package com.opensymphony.module.sitemesh.taglib.decorator;
11
12 import com.opensymphony.module.sitemesh.taglib.AbstractTag;
13
14 /**
15  * Write the Page <code>&lt;title&gt;</code> value to out.
16  *
17  * @author <a HREF="joe@truemesh.com">Joe Walnes</a>
18  * @version $Revision: 1.3 $
19  *
20  * @see com.opensymphony.module.sitemesh.HTMLPage#getTitle()
21  */

22 public class TitleTag extends AbstractTag {
23     private String JavaDoc defaultTitle = null;
24
25     /** Value to write if no title is found (optional). */
26     public void setDefault(String JavaDoc defaultTitle) {
27         this.defaultTitle = defaultTitle;
28     }
29
30     public final int doEndTag() {
31         try {
32             String JavaDoc title = getPage().getTitle();
33             if (title == null || title.trim().length() == 0) title = defaultTitle;
34             if (title != null) getOut().write(title);
35         }
36         catch (Exception JavaDoc e) {
37             trace(e);
38         }
39         return EVAL_PAGE;
40     }
41
42 }
Popular Tags