KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > deprecated > taglibs > field > file > FileFieldAbstract


1 package org.jahia.deprecated.taglibs.field.file;
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.data.files.JahiaFileField;
12 import org.jahia.utils.JahiaConsole;
13
14
15
16 /**
17  * Class FileFieldAbstractTag : abstract class for the FileField tag
18  * This class will be extended by all the classes which
19  * want to display a JahiaFileField attribute.
20  * It retrieves the current JahiaFileField and call a method
21  * which returns an attribute of this object.
22  * The attribute is defined in each subclass.
23  *
24  * @author Jerome Tamiotti
25  */

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