Rev 1306 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | fvelez | 1 | /* |
2 | * writeDocumentPropertyTimes.java |
||
3 | * |
||
4 | * Created on 1 de Abril de 2003, 20:36 |
||
5 | */ |
||
6 | |||
7 | package jomm.web.tags; |
||
8 | |||
9 | /** |
||
10 | * |
||
11 | * @author Jorge Machado |
||
12 | */ |
||
13 | |||
14 | import org.apache.log4j.Logger; |
||
15 | import org.apache.struts.util.RequestUtils; |
||
16 | |||
17 | import javax.servlet.jsp.JspException; |
||
18 | import javax.servlet.jsp.JspWriter; |
||
19 | import javax.servlet.jsp.tagext.BodyTagSupport; |
||
20 | |||
21 | public class NotEqualBeansTag extends BodyTagSupport{ |
||
22 | |||
23 | private static 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(NotEqualBeansTag.class); |
||
24 | |||
25 | |||
26 | |||
27 | /** |
||
28 | * Name of the bean that contains the data we will be rendering. |
||
29 | */ |
||
30 | protected 1.5.0/docs/api/java/lang/String.html">String name1 = null; |
||
31 | |||
32 | public 1.5.0/docs/api/java/lang/String.html">String getName1() { |
||
33 | return (this.name1); |
||
34 | } |
||
35 | |||
36 | public void setName1(1.5.0/docs/api/java/lang/String.html">String name1) { |
||
37 | this.name1 = name1; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Name of the bean that contains the data we will be rendering. |
||
42 | */ |
||
43 | protected 1.5.0/docs/api/java/lang/String.html">String name2 = null; |
||
44 | |||
45 | public 1.5.0/docs/api/java/lang/String.html">String getName2() { |
||
46 | return (this.name2); |
||
47 | } |
||
48 | |||
49 | public void setName2(1.5.0/docs/api/java/lang/String.html">String name2) { |
||
50 | this.name2= name2; |
||
51 | } |
||
52 | /** |
||
53 | * Name of the property to be accessed on the specified bean. |
||
54 | */ |
||
55 | protected 1.5.0/docs/api/java/lang/String.html">String property1 = null; |
||
56 | |||
57 | public 1.5.0/docs/api/java/lang/String.html">String getProperty1() { |
||
58 | return (this.property1); |
||
59 | } |
||
60 | |||
61 | public void setProperty1(1.5.0/docs/api/java/lang/String.html">String property1) { |
||
62 | this.property1 = property1; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Name of the property to be accessed on the specified bean. |
||
67 | */ |
||
68 | protected 1.5.0/docs/api/java/lang/String.html">String property2 = null; |
||
69 | |||
70 | public 1.5.0/docs/api/java/lang/String.html">String getProperty2() { |
||
71 | return (this.property2); |
||
72 | } |
||
73 | |||
74 | public void setProperty2(1.5.0/docs/api/java/lang/String.html">String property2) { |
||
75 | this.property2 = property2; |
||
76 | } |
||
77 | |||
78 | |||
79 | /** |
||
80 | * The scope to be searched to retrieve the specified bean. |
||
81 | */ |
||
82 | protected 1.5.0/docs/api/java/lang/String.html">String scope = null; |
||
83 | |||
84 | public 1.5.0/docs/api/java/lang/String.html">String getScope() { |
||
85 | return (this.scope); |
||
86 | } |
||
87 | |||
88 | public void setScope(1.5.0/docs/api/java/lang/String.html">String scope) { |
||
89 | this.scope = scope; |
||
90 | } |
||
91 | |||
92 | |||
93 | public int doStartTag() throws JspException { |
||
94 | return EVAL_BODY_TAG; |
||
95 | } |
||
96 | public int doEndTag() throws JspException { |
||
97 | |||
98 | // Look up the requested bean (if necessary) |
||
99 | 5+0%2Fdocs%2Fapi+Object">Object bean = null; |
||
100 | |||
101 | // Look up the requested property value |
||
102 | 5+0%2Fdocs%2Fapi+Object">Object value1 = |
||
103 | RequestUtils.lookup(pageContext, name1, property1, null); |
||
104 | 5+0%2Fdocs%2Fapi+Object">Object value2 = |
||
105 | RequestUtils.lookup(pageContext, name2, property2, null); |
||
106 | |||
107 | |||
108 | if (value1 == null || value2 == null) |
||
109 | throw new JspException("pubperiodic:Error bean 1 or bean 2 are null"); |
||
110 | |||
111 | if(!value1.equals(value2) && bodyContent != null) |
||
112 | { |
||
113 | 1.5.0/docs/api/java/lang/String.html">String toPage = bodyContent.getString().trim(); |
||
114 | JspWriter writer = pageContext.getOut(); |
||
115 | try{ |
||
116 | writer.write(toPage); |
||
117 | } |
||
118 | catch(1.5.0/docs/api/java/lang/Exception.html">Exception e) |
||
119 | { |
||
120 | logger.error(e,e); |
||
121 | throw new JspException(e); |
||
122 | } |
||
123 | } |
||
124 | |||
125 | // Continue processing this page |
||
126 | return EVAL_PAGE; |
||
127 | } |
||
128 | |||
129 | |||
130 | } |