Source Code Cross Referenced for UpDownSelect.java in  » Web-Framework » struts-2.0.11 » org » apache » struts2 » 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 » Web Framework » struts 2.0.11 » org.apache.struts2.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: UpDownSelect.java 497654 2007-01-19 00:21:57Z rgielen $
003:         *
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *  http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:        package org.apache.struts2.components;
022:
023:        import java.util.LinkedHashMap;
024:        import java.util.Map;
025:
026:        import javax.servlet.http.HttpServletRequest;
027:        import javax.servlet.http.HttpServletResponse;
028:
029:        import org.apache.commons.logging.Log;
030:        import org.apache.commons.logging.LogFactory;
031:        import org.apache.struts2.views.annotations.StrutsTag;
032:        import org.apache.struts2.views.annotations.StrutsTagAttribute;
033:
034:        import com.opensymphony.xwork2.util.ValueStack;
035:
036:        /**
037:         * <!-- START SNIPPET: javadoc -->
038:         *
039:         * Create a Select component with buttons to move the elements in the select component
040:         * up and down. When the containing form is submited, its elements will be submitted in
041:         * the order they are arranged (top to bottom).
042:         *
043:         * <!-- END SNIPPET: javadoc -->
044:         *
045:         * <p/>
046:         *
047:         * <pre>
048:         * <!-- START SNIPPET: example -->
049:         *
050:         * &lt;!-- Example 1: simple example --&gt;
051:         * &lt;s:updownselect
052:         * list="#{'england':'England', 'america':'America', 'germany':'Germany'}"
053:         * name="prioritisedFavouriteCountries"
054:         * headerKey="-1"
055:         * headerValue="--- Please Order Them Accordingly ---"
056:         * emptyOption="true" /&gt;
057:         *
058:         * &lt;!-- Example 2: more complex example --&gt;
059:         * &lt;s:updownselect
060:         * list="defaultFavouriteCartoonCharacters"
061:         * name="prioritisedFavouriteCartoonCharacters"
062:         * headerKey="-1"
063:         * headerValue="--- Please Order ---"
064:         * emptyOption="true"
065:         * allowMoveUp="true"
066:         * allowMoveDown="true"
067:         * allowSelectAll="true"
068:         * moveUpLabel="Move Up"
069:         * moveDownLabel="Move Down"
070:         * selectAllLabel="Select All" /&gt;
071:         *
072:         * <!-- END SNIPPET: example -->
073:         * </pre>
074:         *
075:         * @version $Date: 2007-01-18 19:21:57 -0500 (Thu, 18 Jan 2007) $ $Id: UpDownSelect.java 497654 2007-01-19 00:21:57Z rgielen $
076:         *
077:         * @s.tag name="updownselect" tld-body-content="JSP" tld-tag-class="org.apache.struts2.views.jsp.ui.UpDownSelectTag"
078:         * description="Render a up down select element"
079:         */
080:        @StrutsTag(name="updownselect",tldTagClass="org.apache.struts2.views.jsp.ui.UpDownSelectTag",description="Create a Select component with buttons to move the elements in the select component up and down")
081:        public class UpDownSelect extends Select {
082:
083:            private static final Log _log = LogFactory
084:                    .getLog(UpDownSelect.class);
085:
086:            final public static String TEMPLATE = "updownselect";
087:
088:            protected String allowMoveUp;
089:            protected String allowMoveDown;
090:            protected String allowSelectAll;
091:
092:            protected String moveUpLabel;
093:            protected String moveDownLabel;
094:            protected String selectAllLabel;
095:
096:            public String getDefaultTemplate() {
097:                return TEMPLATE;
098:            }
099:
100:            public UpDownSelect(ValueStack stack, HttpServletRequest request,
101:                    HttpServletResponse response) {
102:                super (stack, request, response);
103:            }
104:
105:            public void evaluateParams() {
106:                super .evaluateParams();
107:
108:                // override Select's default
109:                if (size == null || size.trim().length() <= 0) {
110:                    addParameter("size", "5");
111:                }
112:                if (multiple == null || multiple.trim().length() <= 0) {
113:                    addParameter("multiple", Boolean.TRUE);
114:                }
115:
116:                if (allowMoveUp != null) {
117:                    addParameter("allowMoveUp", findValue(allowMoveUp,
118:                            Boolean.class));
119:                }
120:                if (allowMoveDown != null) {
121:                    addParameter("allowMoveDown", findValue(allowMoveDown,
122:                            Boolean.class));
123:                }
124:                if (allowSelectAll != null) {
125:                    addParameter("allowSelectAll", findValue(allowSelectAll,
126:                            Boolean.class));
127:                }
128:
129:                if (moveUpLabel != null) {
130:                    addParameter("moveUpLabel", findString(moveUpLabel));
131:                }
132:                if (moveDownLabel != null) {
133:                    addParameter("moveDownLabel", findString(moveDownLabel));
134:                }
135:                if (selectAllLabel != null) {
136:                    addParameter("selectAllLabel", findString(selectAllLabel));
137:                }
138:
139:                // inform our form ancestor about this UpDownSelect so the form knows how to
140:                // auto select all options upon it submission
141:                Form ancestorForm = (Form) findAncestor(Form.class);
142:                if (ancestorForm != null) {
143:
144:                    // inform form ancestor that we are using a custom onsubmit
145:                    enableAncestorFormCustomOnsubmit();
146:
147:                    Map m = (Map) ancestorForm.getParameters().get(
148:                            "updownselectIds");
149:                    if (m == null) {
150:                        // map with key -> id ,  value -> headerKey
151:                        m = new LinkedHashMap();
152:                    }
153:                    m.put(getParameters().get("id"), getParameters().get(
154:                            "headerKey"));
155:                    ancestorForm.getParameters().put("updownselectIds", m);
156:                } else {
157:                    _log
158:                            .warn("no ancestor form found for updownselect "
159:                                    + this 
160:                                    + ", therefore autoselect of all elements upon form submission will not work ");
161:                }
162:            }
163:
164:            public String getAllowMoveUp() {
165:                return allowMoveUp;
166:            }
167:
168:            @StrutsTagAttribute(description="Whether move up button should be displayed",type="Boolean",defaultValue="true")
169:            public void setAllowMoveUp(String allowMoveUp) {
170:                this .allowMoveUp = allowMoveUp;
171:            }
172:
173:            public String getAllowMoveDown() {
174:                return allowMoveDown;
175:            }
176:
177:            @StrutsTagAttribute(description="Whether move down button should be displayed",type="Boolean",defaultValue="true")
178:            public void setAllowMoveDown(String allowMoveDown) {
179:                this .allowMoveDown = allowMoveDown;
180:            }
181:
182:            public String getAllowSelectAll() {
183:                return allowSelectAll;
184:            }
185:
186:            @StrutsTagAttribute(description="Whether or not select all button should be displayed",type="Boolean",defaultValue="true")
187:            public void setAllowSelectAll(String allowSelectAll) {
188:                this .allowSelectAll = allowSelectAll;
189:            }
190:
191:            public String getMoveUpLabel() {
192:                return moveUpLabel;
193:            }
194:
195:            @StrutsTagAttribute(description="Text to display on the move up button",defaultValue="^")
196:            public void setMoveUpLabel(String moveUpLabel) {
197:                this .moveUpLabel = moveUpLabel;
198:            }
199:
200:            public String getMoveDownLabel() {
201:                return moveDownLabel;
202:            }
203:
204:            @StrutsTagAttribute(description="Text to display on the move down button",defaultValue="v")
205:            public void setMoveDownLabel(String moveDownLabel) {
206:                this .moveDownLabel = moveDownLabel;
207:            }
208:
209:            public String getSelectAllLabel() {
210:                return selectAllLabel;
211:            }
212:
213:            @StrutsTagAttribute(description="Text to display on the select all button",defaultValue="*")
214:            public void setSelectAllLabel(String selectAllLabel) {
215:                this.selectAllLabel = selectAllLabel;
216:            }
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.