View Javadoc

1   /*
2    * Criado em 14/01/2005
3    *
4    */
5   package ecar.taglib.util;
6   
7   import java.io.IOException;
8   
9   import javax.servlet.jsp.JspException;
10  import javax.servlet.jsp.JspWriter;
11  import javax.servlet.jsp.PageContext;
12  import javax.servlet.jsp.tagext.Tag;
13  
14  import org.apache.log4j.Logger;
15   
16  /**
17   */
18  public class MensagemObrigatorioTag implements Tag{
19   
20      String obrigatorio;
21  
22      private PageContext page = null;	
23  
24      /**
25       * Inicializa a montagem da tag para ser adicionada na tela de HTML.<br>
26       * 
27       * @author N/C
28  	 * @since N/C
29  	 * @version N/C
30  	 * @return int
31  	 * @throws JspException
32       */
33      public int doStartTag() throws JspException {
34  		JspWriter writer = this.page.getOut();
35  		StringBuffer s = new StringBuffer();
36  	try{
37  	    if ("*".equals(getObrigatorio())) {
38  		    s.append("<tr>");
39  		    s.append("<td colspan=\"4\">");
40  		    s.append("<div class=\"camposobrigatorios\">* Campos de preenchimento obrigat&oacute;rio</div>");
41  		    s.append("</td>");
42  		    s.append("</tr>");
43  	    } else
44  	        s.append("<tr><td colspan=\"2\">&nbsp;</td></tr>");
45  	    
46  	    writer.print(s);
47  	} catch (Exception e) {
48  	   	try{
49      	    writer.print("Erro na geração da TagLib: " + e.getMessage());
50          	Logger logger = Logger.getLogger(this.getClass());
51          	logger.error(e);
52      	}catch(IOException ioE){
53          	Logger logger = Logger.getLogger(this.getClass());
54          	logger.error(ioE);
55      	}   	
56  	}
57  		return Tag.EVAL_BODY_INCLUDE;
58  	}
59  
60      /**
61       * @author N/C
62  	 * @since N/C
63  	 * @version N/C
64  	 * @param Tag arg0
65       */
66  	public void setParent(Tag arg0) {
67  	}
68  
69  	/**
70  	 * Retorna Tag null.<br>
71  	 * 
72  	 * @author N/C
73  	 * @since N/C
74  	 * @version N/C
75  	 * @return Tag
76  	 */
77  	public Tag getParent() {
78  		return null;
79  	}
80  	
81  	/**
82  	 * Encerra Tag.<br>
83  	 * 
84  	 * @author N/C
85  	 * @since N/C
86  	 * @version N/C
87  	 * @return int
88  	 * @throws JspException
89  	 */
90  	public int doEndTag() throws JspException {
91  		return Tag.EVAL_PAGE;
92  	}
93  
94  	/**
95  	 * @author N/C
96  	 * @since N/C
97  	 * @version N/C
98  	 */
99  	public void release() {
100 		//this.selected = null;
101 	}
102 	
103     /**
104      * Retorna PageContext page.<br>
105      * 
106      * @author N/C
107 	 * @since N/C
108 	 * @version N/C
109      * @return PageContext - (Returns the page)
110      */
111     public PageContext getPage() {
112         return page;
113     }
114     
115     /**
116      * Atribui valor especificado para PageContext page.<br>
117      * 
118      * @author N/C
119 	 * @since N/C
120 	 * @version N/C
121      * @param PageContext page - (The page to set)
122      */
123     public void setPage(PageContext page) {
124         this.page = page;
125     }
126 
127     /**
128      * Retorna PageContext page.<br>
129      * 
130      * @author N/C
131 	 * @since N/C
132 	 * @version N/C
133 	 * @param PageContext arg0
134      */
135     public void setPageContext(PageContext arg0) {
136 		this.page = arg0;
137 	}
138 
139     /**
140      * Retorna String obrigatorio.<br>
141      * 
142      * @author N/C
143 	 * @since N/C
144 	 * @version N/C
145      * @return String - (Returns the obrigatorio)
146      */
147     public String getObrigatorio() {
148         return obrigatorio;
149     }
150     
151     /**
152      * Atribui valor especificado para String obrigatorio.<br>
153      * 
154      * @author N/C
155 	 * @since N/C
156 	 * @version N/C
157      * @param String obrigatorio - (The obrigatorio to set)
158      */
159     public void setObrigatorio(String obrigatorio) {
160         this.obrigatorio = obrigatorio;
161     }
162 }