KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > improve > struts > taglib > layout > ImageTag


1 package fr.improve.struts.taglib.layout;
2
3 import javax.servlet.jsp.JspException JavaDoc;
4
5 import org.apache.struts.Globals;
6
7 import fr.improve.struts.taglib.layout.skin.Skin;
8 import fr.improve.struts.taglib.layout.util.LayoutUtils;
9
10 /**
11  * @author: Jean-NoŽl Ribette
12  */

13 public class ImageTag extends ActionTag {
14     protected String JavaDoc src;
15     protected String JavaDoc srcKey;
16     protected String JavaDoc property ="";
17     protected String JavaDoc pageKey;
18     protected String JavaDoc page;
19     protected String JavaDoc locale = Globals.LOCALE_KEY;
20     protected String JavaDoc bundle = Globals.MESSAGES_KEY;
21     protected String JavaDoc border;
22     protected String JavaDoc altKey;
23     protected String JavaDoc alt;
24     protected String JavaDoc name;
25     public ImageTag() {
26         tag = new org.apache.struts.taglib.html.ImageTag();
27     }
28 /**
29  * Insert the method's description here.
30  * Creation date: (20/04/01 10:53:47)
31  * @return java.lang.String
32  */

33 public java.lang.String JavaDoc getAlt() {
34     return alt;
35 }
36 /**
37  * Insert the method's description here.
38  * Creation date: (20/04/01 10:53:47)
39  * @return java.lang.String
40  */

41 public java.lang.String JavaDoc getAltKey() {
42     return altKey;
43 }
44 /**
45  * Insert the method's description here.
46  * Creation date: (20/04/01 10:53:47)
47  * @return java.lang.String
48  */

49 public java.lang.String JavaDoc getBorder() {
50     return border;
51 }
52 /**
53  * Insert the method's description here.
54  * Creation date: (20/04/01 10:53:47)
55  * @return java.lang.String
56  */

57 public java.lang.String JavaDoc getBundle() {
58     return bundle;
59 }
60 /**
61  * Insert the method's description here.
62  * Creation date: (20/04/01 10:53:47)
63  * @return java.lang.String
64  */

65 public java.lang.String JavaDoc getLocale() {
66     return locale;
67 }
68 /**
69  * Insert the method's description here.
70  * Creation date: (20/04/01 10:53:47)
71  * @return java.lang.String
72  */

73 public java.lang.String JavaDoc getPage() {
74     return page;
75 }
76 /**
77  * Insert the method's description here.
78  * Creation date: (20/04/01 10:53:47)
79  * @return java.lang.String
80  */

81 public java.lang.String JavaDoc getPageKey() {
82     return pageKey;
83 }
84 /**
85  * Insert the method's description here.
86  * Creation date: (20/04/01 10:53:47)
87  * @return java.lang.String
88  */

89 public java.lang.String JavaDoc getProperty() {
90     return property;
91 }
92 /**
93  * Insert the method's description here.
94  * Creation date: (20/04/01 10:53:47)
95  * @return java.lang.String
96  */

97 public java.lang.String JavaDoc getSrc() {
98     return src;
99 }
100 /**
101  * Insert the method's description here.
102  * Creation date: (20/04/01 10:53:47)
103  * @return java.lang.String
104  */

105 public java.lang.String JavaDoc getSrcKey() {
106     return srcKey;
107 }
108     public void release() {
109         super.release();
110         src = null;
111         srcKey = null;
112         property = "";
113         pageKey = null;
114         page = null;
115         locale = Globals.LOCALE_KEY;
116         bundle = Globals.MESSAGES_KEY;
117         altKey = null;
118         alt = null;
119         name = null;
120         tag.release();
121     }
122 /**
123  * Insert the method's description here.
124  * Creation date: (20/04/01 10:53:47)
125  * @param newAlt java.lang.String
126  */

127 public void setAlt(java.lang.String JavaDoc newAlt) {
128     alt = newAlt;
129 }
130 /**
131  * Insert the method's description here.
132  * Creation date: (20/04/01 10:53:47)
133  * @param newAltKey java.lang.String
134  */

135 public void setAltKey(java.lang.String JavaDoc newAltKey) {
136     altKey = newAltKey;
137 }
138 /**
139  * Insert the method's description here.
140  * Creation date: (20/04/01 10:53:47)
141  * @param newBorder java.lang.String
142  */

143 public void setBorder(java.lang.String JavaDoc newBorder) {
144     border = newBorder;
145 }
146 /**
147  * Insert the method's description here.
148  * Creation date: (20/04/01 10:53:47)
149  * @param newBundle java.lang.String
150  */

151 public void setBundle(java.lang.String JavaDoc newBundle) {
152     bundle = newBundle;
153 }
154 /**
155  * Insert the method's description here.
156  * Creation date: (20/04/01 10:53:47)
157  * @param newLocale java.lang.String
158  */

159 public void setLocale(java.lang.String JavaDoc newLocale) {
160     locale = newLocale;
161 }
162 /**
163  * Insert the method's description here.
164  * Creation date: (20/04/01 10:53:47)
165  * @param newPage java.lang.String
166  */

167 public void setPage(java.lang.String JavaDoc newPage) {
168     page = newPage;
169 }
170 /**
171  * Insert the method's description here.
172  * Creation date: (20/04/01 10:53:47)
173  * @param newPageKey java.lang.String
174  */

175 public void setPageKey(java.lang.String JavaDoc newPageKey) {
176     pageKey = newPageKey;
177 }
178 /**
179  * Insert the method's description here.
180  * Creation date: (20/04/01 10:53:47)
181  * @param newProperty java.lang.String
182  */

183 public void setProperty(java.lang.String JavaDoc newProperty) {
184     property = newProperty;
185 }
186 /**
187  * Insert the method's description here.
188  * Creation date: (20/04/01 10:53:47)
189  * @param newSrc java.lang.String
190  */

191 public void setSrc(java.lang.String JavaDoc newSrc) {
192     src = newSrc;
193 }
194 /**
195  * Insert the method's description here.
196  * Creation date: (20/04/01 10:53:47)
197  * @param newSrcKey java.lang.String
198  */

199 public void setSrcKey(java.lang.String JavaDoc newSrcKey) {
200     srcKey = newSrcKey;
201 }
202     protected void copyProperties() throws JspException JavaDoc {
203         // Super copy
204
super.copyProperties();
205         
206         // copy struts-layout image src if set.
207
if (name!=null) {
208             // Create StringBuffer.
209
StringBuffer JavaDoc lc_buffer = new StringBuffer JavaDoc();
210             
211             // Get skin
212
Skin lc_skin = LayoutUtils.getSkin(pageContext.getSession());
213             
214             // Get image directory
215
String JavaDoc lc_imgSrc = lc_skin.getImageDirectory(pageContext.getRequest());
216             lc_buffer.append(lc_imgSrc);
217             if (!lc_imgSrc.endsWith("/") && !name.startsWith("/")) {
218                 lc_buffer.append('/');
219             }
220             
221             // Get image name
222
lc_buffer.append(name);
223             // Set image src.
224
((org.apache.struts.taglib.html.ImageTag) tag).setSrc(lc_buffer.toString());
225         }
226     }
227     public String JavaDoc getName() {
228         return name;
229     }
230     public void setName(String JavaDoc name) {
231         this.name = name;
232     }
233 }
234
Popular Tags