View Javadoc

1   /*
2    * Created on 13/12/2004
3    *
4    */
5   package ecar.taglib.util;
6   
7   import javax.servlet.jsp.JspException;
8   import javax.servlet.jsp.JspWriter;
9   import javax.servlet.jsp.tagext.Tag;
10  import javax.servlet.jsp.tagext.TagSupport;
11  
12  import org.apache.log4j.Logger;
13  
14  
15  /**
16   * @author garten
17   *
18   */
19  public class BarraPesquisaTag extends TagSupport {
20  
21  	/**
22  	 * 
23  	 */
24  	private static final long serialVersionUID = 8613849191957082475L;
25  
26  	private Logger logger = Logger.getLogger(this.getClass());
27  
28  	// constantes da sintaxe do html
29  	//private final String ASPAS = "\"";
30  	//private final String DIVISAO = "";
31  	
32  	// parametros da taglib
33  	private int atual;
34  	private int total;
35  
36  	/**
37  	 * Inicializa a montagem da tag para ser adicionada na tela de HTML.<br>
38  	 * 
39  	 * @author N/C
40  	 * @since N/C
41  	 * @version N/C
42  	 * @return int
43  	 * @throws JspException
44  	 */
45  	public int doStartTag() throws JspException {
46  		JspWriter writer = this.pageContext.getOut();
47  		
48  		try {
49  			writer.println("<table class=\"barrabotoes\" cellpadding=\"0\" cellspacing=\"0\">");
50  			writer.println("<tr>");
51  
52  			writer.println("<td width=\"20%\" align=\"left\">");
53  			writer.println("<input name=\"btnPrimeiro\" type=\"button\" value=\"<<\" class=\"botao\" onclick=\"aoClicarPrimeiro(form);\">");
54  			writer.println("<input name=\"btnAnterior\" type=\"button\" value=\"<\" class=\"botao\" onclick=\"aoClicarAnterior(form);\">");
55  			writer.println("</td>");
56  
57  			writer.println("<td align=\"center\" width=\"60%\">");
58  			if (this.getAtual() != 0)
59  			    writer.print("P&aacute;gina " + this.getAtual());
60  			
61  			if (this.getTotal() != 0) {
62  				if (this.getAtual() != 0)
63  				    writer.print(" de ");
64  			    writer.println(this.getTotal());
65  			}
66  			writer.println("</td>");
67  			
68  			
69  			writer.println("<td width=\"20%\" align=\"right\">");
70  			writer.println("<input name=\"btnProximo\" type=\"button\" value=\">\" class=\"botao\" onclick=\"aoClicarProximo(form);\">");
71  			writer.println("<input name=\"btnUltimo\" type=\"button\" value=\">>\" class=\"botao\" onclick=\"aoClicarUltimo(form);\">");
72  			writer.println("</td>");
73  
74  			writer.println("</tr>");
75  			writer.println("</table>");
76  		} catch (Exception e) {
77  			logger.error(e);
78  		}
79  		/* nao processa o conteudo do corpo da tag, porque nao existe */
80  		return Tag.SKIP_BODY;
81  	}
82  
83  	/**
84  	 * Encerra Tag.<br>
85  	 * 
86  	 * @author N/C
87  	 * @since N/C
88  	 * @version N/C
89  	 * @return int
90  	 * @throws JspException
91  	 */
92  	public int doEndTag() throws JspException {
93  	    /* processa o restante da página jsp */
94  		return Tag.EVAL_PAGE;
95  	}
96  
97      /**
98       * Retorna int atual.<br>
99       * 
100      * @author N/C
101 	 * @since N/C
102 	 * @version N/C
103      * @return int - (Returns the atual)
104      */
105     public int getAtual() {
106         return atual;
107     }
108     
109     /**
110      * Atribui valor especificado para int atual.<br>
111      * 
112      * @author N/C
113 	 * @since N/C
114 	 * @version N/C
115      * @param int atual - (The atual to set)
116      */
117     public void setAtual(int atual) {
118         this.atual = atual;
119     }
120     
121     /**
122      * Retorna int total.<br>
123      * 
124      * @author N/C
125 	 * @since N/C
126 	 * @version N/C
127      * @return int - (Returns the total)
128      */
129     public int getTotal() {
130         return total;
131     }
132     
133     /**
134      * Atribui valor especificado para int total.<br>
135      * 
136      * @author N/C
137 	 * @since N/C
138 	 * @version N/C
139      * @param int total - (The total to set)
140      */
141     public void setTotal(int total) {
142         this.total = total;
143     }
144 }