Source Code Cross Referenced for OptionTransferSelect.java in  » J2EE » webwork-2.2.6 » com » opensymphony » webwork » components » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » webwork 2.2.6 » com.opensymphony.webwork.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2002-2003 by OpenSymphony
003:         * All rights reserved.
004:         */
005:        package com.opensymphony.webwork.components;
006:
007:        import java.util.ArrayList;
008:        import java.util.LinkedHashMap;
009:        import java.util.List;
010:        import java.util.Map;
011:
012:        import javax.servlet.http.HttpServletRequest;
013:        import javax.servlet.http.HttpServletResponse;
014:
015:        import org.apache.commons.logging.Log;
016:        import org.apache.commons.logging.LogFactory;
017:
018:        import com.opensymphony.xwork.util.OgnlValueStack;
019:
020:        /**
021:         * <!-- START SNIPPET: javadoc -->
022:         * 
023:         * Create a option transfer select component which is basically two &lt;select ...&gt;
024:         * tag with buttons in the middle of them allowing options in each of the 
025:         * &lt;select ...&gt; to be moved between themselves. Will auto-select all its 
026:         * elements upon its containing form submision.
027:         * 
028:         * <!-- END SNIPPET: javadoc -->
029:         * 
030:         * <p/>
031:         * 
032:         * 
033:         * <!-- START SNIPPET: notice -->
034:         * 
035:         * NOTE: The id and doubleId need not be supplied as they will generated provided
036:         * that the optiontransferselect tag is being used in a form tag. The generated id 
037:         * and doubleId will be &lt;form_id&gt;_&lt;optiontransferselect_doubleName&gt; and 
038:         * &lt;form_id&gt;_&lt;optiontransferselect_doubleName&gt; respectively.
039:         * 
040:         * <!-- END SNIPPET: notice -->
041:         * 
042:         * <p/>
043:         * 
044:         * <pre>
045:         * <!-- START SNIPPET: example -->
046:         * 
047:         * &lt;-- minimum configuration --&gt;
048:         * &lt;ww:optiontransferselect 
049:         *   	label="Favourite Cartoons Characters"
050:         *		name="leftSideCartoonCharacters" 
051:         *		list="{'Popeye', 'He-Man', 'Spiderman'}" 
052:         *		doubleName="rightSideCartoonCharacters"
053:         *		doubleList="{'Superman', 'Mickey Mouse', 'Donald Duck'}" 
054:         *	/&gt;
055:         *
056:         *  &lt;-- possible configuration --&gt;
057:         *  &lt;ww:optiontransferselect 
058:         *   	label="Favourite Cartoons Characters"
059:         *		name="leftSideCartoonCharacters" 
060:         *		leftTitle="Left Title"
061:         *		rightTitle="Right Title"
062:         *		list="{'Popeye', 'He-Man', 'Spiderman'}" 
063:         *		multiple="true"
064:         *		headerKey="headerKey"
065:         *		headerValue="--- Please Select ---"
066:         *		emptyOption="true"
067:         *		doubleList="{'Superman', 'Mickey Mouse', 'Donald Duck'}" 
068:         *		doubleName="rightSideCartoonCharacters"
069:         *		doubleHeaderKey="doubleHeaderKey"
070:         *		doubleHeaderValue="--- Please Select ---" 
071:         *		doubleEmptyOption="true"
072:         *		doubleMultiple="true"
073:         *	/&gt;
074:         * 
075:         * <!-- END SNIPPET: example -->
076:         * </pre>
077:         * 
078:         * 
079:         * @author tm_jee
080:         * @version $Date: 2006-03-18 17:28:55 +0100 (Sat, 18 Mar 2006) $ $Id: OptionTransferSelect.java 2468 2006-03-18 16:28:55Z rgielen $
081:         * @ww.tag name="optiontransferselect" tld-body-content="JSP" tld-tag-class="com.opensymphony.webwork.views.jsp.ui.OptionTransferSelectTag"
082:         * description="Renders an input form"
083:         */
084:        public class OptionTransferSelect extends DoubleListUIBean {
085:
086:            private static final Log _log = LogFactory
087:                    .getLog(OptionTransferSelect.class);
088:
089:            private static final String TEMPLATE = "optiontransferselect";
090:
091:            protected String allowAddToLeft;
092:            protected String allowAddToRight;
093:            protected String allowAddAllToLeft;
094:            protected String allowAddAllToRight;
095:            protected String allowSelectAll;
096:
097:            protected String leftTitle;
098:            protected String rightTitle;
099:
100:            protected String buttonCssClass;
101:            protected String buttonCssStyle;
102:
103:            protected String addToLeftLabel;
104:            protected String addToRightLabel;
105:            protected String addAllToLeftLabel;
106:            protected String addAllToRightLabel;
107:            protected String selectAllLabel;
108:
109:            public OptionTransferSelect(OgnlValueStack stack,
110:                    HttpServletRequest request, HttpServletResponse response) {
111:                super (stack, request, response);
112:            }
113:
114:            protected String getDefaultTemplate() {
115:                return TEMPLATE;
116:            }
117:
118:            public void evaluateExtraParams() {
119:                super .evaluateExtraParams();
120:
121:                Object doubleValue = null;
122:
123:                // override DoubleListUIBean's 
124:                if (doubleList != null) {
125:                    doubleValue = findValue(doubleList);
126:                    addParameter("doubleList", doubleValue);
127:                }
128:                if (size == null || size.trim().length() <= 0) {
129:                    addParameter("size", "15");
130:                }
131:                if (doubleSize == null || doubleSize.trim().length() <= 0) {
132:                    addParameter("doubleSize", "15");
133:                }
134:                if (multiple == null || multiple.trim().length() <= 0) {
135:                    addParameter("multiple", Boolean.TRUE);
136:                }
137:                if (doubleMultiple == null
138:                        || doubleMultiple.trim().length() <= 0) {
139:                    addParameter("doubleMultiple", Boolean.TRUE);
140:                }
141:
142:                // buttonCssClass 
143:                if (buttonCssClass != null
144:                        && buttonCssClass.trim().length() > 0) {
145:                    addParameter("buttonCssClass", buttonCssClass);
146:                }
147:
148:                // buttonCssStyle
149:                if (buttonCssStyle != null
150:                        && buttonCssStyle.trim().length() > 0) {
151:                    addParameter("buttonCssStyle", buttonCssStyle);
152:                }
153:
154:                // allowSelectAll
155:                addParameter("allowSelectAll",
156:                        allowSelectAll != null ? findValue(allowSelectAll,
157:                                Boolean.class) : Boolean.TRUE);
158:
159:                // allowAddToLeft
160:                addParameter("allowAddToLeft",
161:                        allowAddToLeft != null ? findValue(allowAddToLeft,
162:                                Boolean.class) : Boolean.TRUE);
163:
164:                // allowAddToRight
165:                addParameter("allowAddToRight",
166:                        allowAddToRight != null ? findValue(allowAddToRight,
167:                                Boolean.class) : Boolean.TRUE);
168:
169:                // allowAddAllToLeft
170:                addParameter("allowAddAllToLeft",
171:                        allowAddAllToLeft != null ? findValue(
172:                                allowAddAllToLeft, Boolean.class)
173:                                : Boolean.TRUE);
174:
175:                // allowAddAllToRight
176:                addParameter("allowAddAllToRight",
177:                        allowAddAllToRight != null ? findValue(
178:                                allowAddAllToRight, Boolean.class)
179:                                : Boolean.TRUE);
180:
181:                // leftTitle
182:                if (leftTitle != null) {
183:                    addParameter("leftTitle",
184:                            findValue(leftTitle, String.class));
185:                }
186:
187:                // rightTitle
188:                if (rightTitle != null) {
189:                    addParameter("rightTitle", findValue(rightTitle,
190:                            String.class));
191:                }
192:
193:                // addToLeftLabel
194:                addParameter("addToLeftLabel",
195:                        addToLeftLabel != null ? findValue(addToLeftLabel,
196:                                String.class) : "<-");
197:
198:                // addToRightLabel
199:                addParameter("addToRightLabel",
200:                        addToRightLabel != null ? findValue(addToRightLabel,
201:                                String.class) : "->");
202:
203:                // addAllToLeftLabel
204:                addParameter("addAllToLeftLabel",
205:                        addAllToLeftLabel != null ? findValue(
206:                                addAllToLeftLabel, String.class) : "<<--");
207:
208:                // addAllToRightLabel
209:                addParameter("addAllToRightLabel",
210:                        addAllToRightLabel != null ? findValue(
211:                                addAllToRightLabel, String.class) : "-->>");
212:
213:                // selectAllLabel
214:                addParameter("selectAllLabel",
215:                        selectAllLabel != null ? findValue(selectAllLabel,
216:                                String.class) : "<*>");
217:
218:                // inform the form component our select tag infos, so they know how to select 
219:                // its elements upon onsubmit
220:                Form formAncestor = (Form) findAncestor(Form.class);
221:                if (formAncestor != null) {
222:
223:                    // inform ancestor form that we are having a customOnsubmit (see form-close.ftl [simple theme])
224:                    enableAncestorFormCustomOnsubmit();
225:
226:                    // key -> select tag id, value -> headerKey (if exists)
227:                    Map formOptiontransferselectIds = (Map) formAncestor
228:                            .getParameters().get("optiontransferselectIds");
229:                    Map formOptiontransferselectDoubleIds = (Map) formAncestor
230:                            .getParameters().get(
231:                                    "optiontransferselectDoubleIds");
232:
233:                    // init lists
234:                    if (formOptiontransferselectIds == null) {
235:                        formOptiontransferselectIds = new LinkedHashMap();
236:                    }
237:                    if (formOptiontransferselectDoubleIds == null) {
238:                        formOptiontransferselectDoubleIds = new LinkedHashMap();
239:                    }
240:
241:                    // id
242:                    String tmpId = (String) getParameters().get("id");
243:                    String tmpHeaderKey = (String) getParameters().get(
244:                            "headerKey");
245:                    if (tmpId != null
246:                            && (!formOptiontransferselectIds.containsKey(tmpId))) {
247:                        formOptiontransferselectIds.put(tmpId, tmpHeaderKey);
248:                    }
249:
250:                    // doubleId
251:                    String tmpDoubleId = (String) getParameters().get(
252:                            "doubleId");
253:                    String tmpDoubleHeaderKey = (String) getParameters().get(
254:                            "doubleHeaderKey");
255:                    if (tmpDoubleId != null
256:                            && (!formOptiontransferselectDoubleIds
257:                                    .containsKey(tmpDoubleId))) {
258:                        formOptiontransferselectDoubleIds.put(tmpDoubleId,
259:                                tmpDoubleHeaderKey);
260:                    }
261:
262:                    formAncestor.getParameters().put("optiontransferselectIds",
263:                            formOptiontransferselectIds);
264:                    formAncestor.getParameters().put(
265:                            "optiontransferselectDoubleIds",
266:                            formOptiontransferselectDoubleIds);
267:
268:                } else {
269:                    _log
270:                            .warn("form enclosing optiontransferselect "
271:                                    + this 
272:                                    + " not found, auto select upon form submit of optiontransferselect will not work");
273:                }
274:            }
275:
276:            public String getAddAllToLeftLabel() {
277:                return addAllToLeftLabel;
278:            }
279:
280:            /**
281:             * set Add To Left button label
282:             * @ww.tagattribute required="false"
283:             */
284:            public void setAddAllToLeftLabel(String addAllToLeftLabel) {
285:                this .addAllToLeftLabel = addAllToLeftLabel;
286:            }
287:
288:            public String getAddAllToRightLabel() {
289:                return addAllToRightLabel;
290:            }
291:
292:            /**
293:             * set Add All To Right button label
294:             * @ww.tagattribute required="false"
295:             */
296:            public void setAddAllToRightLabel(String addAllToRightLabel) {
297:                this .addAllToRightLabel = addAllToRightLabel;
298:            }
299:
300:            public String getAddToLeftLabel() {
301:                return addToLeftLabel;
302:            }
303:
304:            /**
305:             * set Add To Left button label
306:             * @ww.tagattribute required="false"
307:             */
308:            public void setAddToLeftLabel(String addToLeftLabel) {
309:                this .addToLeftLabel = addToLeftLabel;
310:            }
311:
312:            public String getAddToRightLabel() {
313:                return addToRightLabel;
314:            }
315:
316:            /**
317:             * set Add To Right button label
318:             * @ww.tagattribute required="false"
319:             */
320:            public void setAddToRightLabel(String addToRightLabel) {
321:                this .addToRightLabel = addToRightLabel;
322:            }
323:
324:            public String getAllowAddAllToLeft() {
325:                return allowAddAllToLeft;
326:            }
327:
328:            /**
329:             * enable Add All To Left button
330:             * @ww.tagattribute required="false"
331:             */
332:            public void setAllowAddAllToLeft(String allowAddAllToLeft) {
333:                this .allowAddAllToLeft = allowAddAllToLeft;
334:            }
335:
336:            public String getAllowAddAllToRight() {
337:                return allowAddAllToRight;
338:            }
339:
340:            /**
341:             * enable Add All To Right button
342:             * @ww.tagattribute required="false"
343:             */
344:            public void setAllowAddAllToRight(String allowAddAllToRight) {
345:                this .allowAddAllToRight = allowAddAllToRight;
346:            }
347:
348:            public String getAllowAddToLeft() {
349:                return allowAddToLeft;
350:            }
351:
352:            /**
353:             * enable Add To Left button
354:             * @ww.tagattribute required="false"
355:             */
356:            public void setAllowAddToLeft(String allowAddToLeft) {
357:                this .allowAddToLeft = allowAddToLeft;
358:            }
359:
360:            public String getAllowAddToRight() {
361:                return allowAddToRight;
362:            }
363:
364:            /**
365:             * enable Add To Right button
366:             * @ww.tagattribute required="false"
367:             */
368:            public void setAllowAddToRight(String allowAddToRight) {
369:                this .allowAddToRight = allowAddToRight;
370:            }
371:
372:            public String getLeftTitle() {
373:                return leftTitle;
374:            }
375:
376:            /**
377:             * set Left title
378:             * @ww.tagattribute required="false"
379:             */
380:            public void setLeftTitle(String leftTitle) {
381:                this .leftTitle = leftTitle;
382:            }
383:
384:            public String getRightTitle() {
385:                return rightTitle;
386:            }
387:
388:            /**
389:             * set Right title
390:             * @ww.tagattribute required="false"
391:             */
392:            public void setRightTitle(String rightTitle) {
393:                this .rightTitle = rightTitle;
394:            }
395:
396:            /**
397:             * enable Select All button
398:             * @ww.tagattribute required="false"
399:             */
400:            public void setAllowSelectAll(String allowSelectAll) {
401:                this .allowSelectAll = allowSelectAll;
402:            }
403:
404:            public String getAllowSelectAll() {
405:                return this .allowSelectAll;
406:            }
407:
408:            /**
409:             * set Select All button label
410:             * @ww.tagattribute required="false"
411:             */
412:            public void setSelectAllLabel(String selectAllLabel) {
413:                this .selectAllLabel = selectAllLabel;
414:            }
415:
416:            public String getSelectAllLabel() {
417:                return this .selectAllLabel;
418:            }
419:
420:            /**
421:             * set buttons css class
422:             * @ww.tagattribute required="false"
423:             */
424:            public void setButtonCssClass(String buttonCssClass) {
425:                this .buttonCssClass = buttonCssClass;
426:            }
427:
428:            public String getButtonCssClass() {
429:                return buttonCssClass;
430:            }
431:
432:            /**
433:             * set button css style
434:             * @ww.tagattribute required="false"
435:             */
436:            public void setButtonCssStyle(String buttonCssStyle) {
437:                this .buttonCssStyle = buttonCssStyle;
438:            }
439:
440:            public String getButtonCssStyle() {
441:                return this.buttonCssStyle;
442:            }
443:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.