KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > deprecated > taglibs > field > page > PageFieldAbstract


1 package org.jahia.deprecated.taglibs.field.page;
2
3 import java.io.IOException JavaDoc;
4
5 import javax.servlet.ServletRequest JavaDoc;
6 import javax.servlet.jsp.JspException JavaDoc;
7 import javax.servlet.jsp.JspTagException JavaDoc;
8 import javax.servlet.jsp.JspWriter JavaDoc;
9 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
10
11 import org.jahia.services.pages.JahiaPage;
12 import org.jahia.utils.JahiaConsole;
13
14
15 /**
16  * Class PageFieldAbstract : abstract class for the PageField tag
17  *
18  * This class will be extended by all the classes which want to display
19  * a JahiaPageField attribute. It retrieves the current JahiaPageField
20  * and call a method which returns an attribute of this object.
21  * This attribute is defined in each subclass.
22  *
23  * @author Jerome Tamiotti
24  */

25 public abstract class PageFieldAbstract extends TagSupport JavaDoc {
26
27     protected JahiaPage thePage = null;
28
29     public int doStartTag() throws JspTagException JavaDoc {
30
31         ServletRequest JavaDoc request = pageContext.getRequest();
32         // retrieves the enclosing PageField tag
33
PageFieldTag pageTag = (PageFieldTag) findAncestorWithClass(this, PageFieldTag.class);
34         if (pageTag == null) {
35             return SKIP_BODY;
36         }
37         // reads the page
38
thePage = pageTag.getPage();
39         if (thePage == null) {
40             return SKIP_BODY;
41         }
42         try {
43             JspWriter JavaDoc out = pageContext.getOut();
44             out.print(getField());
45         } catch (IOException JavaDoc ioe) {
46             JahiaConsole.println("PageFieldAbstract: doStartTag ",ioe.toString());
47         }
48         return SKIP_BODY;
49     }
50
51     // will be implemented in the classes mentionned above
52
public abstract String JavaDoc getField();
53
54     public int doEndTag() throws JspException JavaDoc {
55         // let's reinitialize the tag variables to allow tag object reuse in
56
// pooling.
57
thePage = null;
58         return EVAL_PAGE;
59     }
60
61
62 }
63
64
Popular Tags