Source Code Cross Referenced for DateTextField.java in  » J2EE » wicket » org » apache » wicket » datetime » markup » html » form » 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 » wicket » org.apache.wicket.datetime.markup.html.form 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.wicket.datetime.markup.html.form;
018:
019:        import java.text.SimpleDateFormat;
020:        import java.util.Date;
021:
022:        import org.apache.wicket.datetime.DateConverter;
023:        import org.apache.wicket.datetime.PatternDateConverter;
024:        import org.apache.wicket.datetime.StyleDateConverter;
025:        import org.apache.wicket.markup.html.form.TextField;
026:        import org.apache.wicket.markup.html.form.AbstractTextComponent.ITextFormatProvider;
027:        import org.apache.wicket.model.IModel;
028:        import org.apache.wicket.util.convert.IConverter;
029:        import org.joda.time.DateTime;
030:        import org.joda.time.DateTimeZone;
031:        import org.joda.time.format.DateTimeFormat;
032:
033:        /**
034:         * A TextField that is mapped to a <code>java.util.Date</code> object and that
035:         * uses Joda time to parse and format values.
036:         * <p>
037:         * You should use on of the factory methods to construct the kind you want or
038:         * use the public constructor and pass in the converter to use.
039:         * </p>
040:         * <p>
041:         * This component tries to apply the time zone difference between the client and
042:         * server. See the
043:         * {@link DateConverter#getApplyTimeZoneDifference() date converter} of this
044:         * package for more information on that.
045:         * </p>
046:         * 
047:         * @see StyleDateConverter
048:         * @see DateTime
049:         * @see DateTimeFormat
050:         * @see DateTimeZone
051:         * 
052:         * @author eelcohillenius
053:         */
054:        public class DateTextField extends TextField implements 
055:                ITextFormatProvider {
056:
057:            private static final long serialVersionUID = 1L;
058:
059:            /**
060:             * Creates a new DateTextField defaulting to using a short date pattern
061:             * 
062:             * @param id
063:             *            The id of the text field
064:             * @param model
065:             *            The model
066:             * @param datePattern
067:             *            The pattern to use. Must be not null. See
068:             *            {@link SimpleDateFormat} for available patterns.
069:             * 
070:             * @see org.apache.wicket.markup.html.form.TextField
071:             */
072:            public static DateTextField forDatePattern(String id, IModel model,
073:                    String datePattern) {
074:                return new DateTextField(id, model, new PatternDateConverter(
075:                        datePattern, true));
076:            }
077:
078:            /**
079:             * Creates a new DateTextField defaulting to using a short date pattern
080:             * 
081:             * @param id
082:             *            The id of the text field
083:             * @param datePattern
084:             *            The pattern to use. Must be not null. See
085:             *            {@link SimpleDateFormat} for available patterns.
086:             * 
087:             * @see org.apache.wicket.markup.html.form.TextField
088:             */
089:            public static DateTextField forDatePattern(String id,
090:                    String datePattern) {
091:                return forDatePattern(id, null, datePattern);
092:            }
093:
094:            /**
095:             * Creates a new DateTextField using the provided date style.
096:             * 
097:             * @param id
098:             *            The id of the text field
099:             * @param model
100:             *            The model
101:             * @param dateStyle
102:             *            Date style to use. The first character is the date style, and
103:             *            the second character is the time style. Specify a character of
104:             *            'S' for short style, 'M' for medium, 'L' for long, and 'F' for
105:             *            full. A date or time may be ommitted by specifying a style
106:             *            character '-'. See {@link DateTimeFormat#forStyle(String)}.
107:             * 
108:             * @see org.apache.wicket.markup.html.form.TextField
109:             */
110:            public static DateTextField forDateStyle(String id, IModel model,
111:                    String dateStyle) {
112:                return new DateTextField(id, model, new StyleDateConverter(
113:                        dateStyle, true));
114:            }
115:
116:            /**
117:             * Creates a new DateTextField using the provided date style.
118:             * 
119:             * @param id
120:             *            The id of the text field
121:             * @param dateStyle
122:             *            Date style to use. The first character is the date style, and
123:             *            the second character is the time style. Specify a character of
124:             *            'S' for short style, 'M' for medium, 'L' for long, and 'F' for
125:             *            full. A date or time may be ommitted by specifying a style
126:             *            character '-'. See {@link DateTimeFormat#forStyle(String)}.
127:             * 
128:             * @see org.apache.wicket.markup.html.form.TextField
129:             */
130:            public static DateTextField forDateStyle(String id, String dateStyle) {
131:                return forDateStyle(id, null, dateStyle);
132:            }
133:
134:            /**
135:             * Creates a new DateTextField defaulting to using a short date pattern
136:             * 
137:             * @param id
138:             *            The id of the text field
139:             * 
140:             * @see org.apache.wicket.markup.html.form.TextField
141:             */
142:            public static DateTextField forShortStyle(String id) {
143:                return forShortStyle(id, null);
144:            }
145:
146:            /**
147:             * Creates a new DateTextField defaulting to using a short date pattern
148:             * 
149:             * @param id
150:             *            The id of the text field
151:             * @param model
152:             *            The model
153:             * 
154:             * @see org.apache.wicket.markup.html.form.TextField
155:             */
156:            public static DateTextField forShortStyle(String id, IModel model) {
157:                return new DateTextField(id, model,
158:                        new StyleDateConverter(true));
159:            }
160:
161:            /**
162:             * Creates a new DateTextField using the provided converter.
163:             * 
164:             * @param id
165:             *            The id of the text field
166:             * @param converter
167:             *            the date converter
168:             * 
169:             * @see org.apache.wicket.markup.html.form.TextField
170:             */
171:            public static DateTextField withConverter(String id,
172:                    DateConverter converter) {
173:                return withConverter(id, null, converter);
174:            }
175:
176:            /**
177:             * Creates a new DateTextField using the provided converter.
178:             * 
179:             * @param id
180:             *            The id of the text field
181:             * @param model
182:             *            The model
183:             * @param converter
184:             *            the date converter
185:             * 
186:             * @see org.apache.wicket.markup.html.form.TextField
187:             */
188:            public static DateTextField withConverter(String id, IModel model,
189:                    DateConverter converter) {
190:                return new DateTextField(id, model, converter);
191:            }
192:
193:            /**
194:             * The converter for the TextField
195:             */
196:            private final DateConverter converter;
197:
198:            /**
199:             * Construct with a converter.
200:             * 
201:             * @param The
202:             *            component id
203:             * @param The
204:             *            model
205:             * @param converter
206:             *            The converter to use
207:             */
208:            public DateTextField(String id, IModel model,
209:                    DateConverter converter) {
210:                super (id, model, Date.class);
211:                if (converter == null) {
212:                    throw new IllegalStateException("converter may not be null");
213:                }
214:                converter.setComponent(this );
215:                this .converter = converter;
216:            }
217:
218:            /**
219:             * @return The specialized converter.
220:             * @see org.apache.wicket.Component#getConverter(java.lang.Class)
221:             */
222:            public final IConverter getConverter(Class clazz) {
223:                return converter;
224:            }
225:
226:            /**
227:             * @see org.apache.wicket.markup.html.form.AbstractTextComponent.ITextFormatProvider#getTextFormat()
228:             */
229:            public final String getTextFormat() {
230:                return converter.getDatePattern();
231:            }
232:        }
w_w_w___.jav__a2_s___._c__o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.