01: /*
02: * Title: TitleTag
03: * Description:
04: *
05: * This software is published under the terms of the OpenSymphony Software
06: * License version 1.1, of which a copy has been included with this
07: * distribution in the LICENSE.txt file.
08: */
09:
10: package com.opensymphony.module.sitemesh.taglib.decorator;
11:
12: import com.opensymphony.module.sitemesh.taglib.AbstractTag;
13:
14: /**
15: * Write the Page <code><title></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 defaultTitle = null;
24:
25: /** Value to write if no title is found (optional). */
26: public void setDefault(String defaultTitle) {
27: this .defaultTitle = defaultTitle;
28: }
29:
30: public final int doEndTag() {
31: try {
32: String title = getPage().getTitle();
33: if (title == null || title.trim().length() == 0)
34: title = defaultTitle;
35: if (title != null)
36: getOut().write(title);
37: } catch (Exception e) {
38: trace(e);
39: }
40: return EVAL_PAGE;
41: }
42:
43: }
|