Repository: wicket
Updated Branches:
  refs/heads/master b1f4e6a34 -> be028e0bb


Factory method for the minutes Textfield

Created new factory method for the minutes Textfield

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/5b05b9f2
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/5b05b9f2
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/5b05b9f2

Branch: refs/heads/master
Commit: 5b05b9f208e99c7d23afcd33985a746a3804bdd6
Parents: 334808b
Author: astrapi69 <[email protected]>
Authored: Thu Jan 8 13:30:09 2015 +0100
Committer: astrapi69 <[email protected]>
Committed: Thu Jan 8 13:30:09 2015 +0100

----------------------------------------------------------------------
 .../extensions/yui/calendar/DateTimeField.java  | 60 +++++++++++++-------
 1 file changed, 39 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/5b05b9f2/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java
----------------------------------------------------------------------
diff --git 
a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java
 
b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java
index aecf57a..5f12638 100644
--- 
a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java
+++ 
b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java
@@ -167,27 +167,8 @@ public class DateTimeField extends FormComponentPanel<Date>
                        Integer.class));
 
                // Create and add the "minutes" TextField
-               add(minutesField = new TextField<Integer>(MINUTES,
-                       new PropertyModel<Integer>(this, MINUTES), 
Integer.class)
-               {
-                       private static final long serialVersionUID = 1L;
-
-                       @SuppressWarnings("unchecked")
-                       @Override
-                       public <C> IConverter<C> getConverter(Class<C> type)
-                       {
-                               if (Integer.class.isAssignableFrom(type))
-                               {
-                                       return (IConverter<C>)MINUTES_CONVERTER;
-                               }
-                               else
-                               {
-                                       return super.getConverter(type);
-                               }
-                       }
-               });
-               minutesField.add(new RangeValidator<>(0, 59));
-               minutesField.setLabel(new Model<>(MINUTES));
+               add(minutesField = newMinutesTextField(MINUTES, new 
PropertyModel<Integer>(this, MINUTES),
+                       Integer.class));
 
                // Create and add the "AM/PM" Listbox
                add(amOrPmChoice = new DropDownChoice<AM_PM>(AM_OR_PM_CHOICE, 
new PropertyModel<AM_PM>(
@@ -225,6 +206,43 @@ public class DateTimeField extends FormComponentPanel<Date>
        }
 
        /**
+        * create a new {@link TextField} instance for minutes to be added to 
this panel.
+        *
+        * @param id
+        *            the component id
+        * @param model
+        *            model that should be used by the {@link TextField}
+        * @param type
+        *            the type of the text field
+        * @return a new text field instance
+        */
+       protected TextField<Integer> newMinutesTextField(final String id, 
IModel<Integer> model,
+               Class<Integer> type)
+       {
+               TextField<Integer> minutesField = new TextField<Integer>(id, 
model, type)
+               {
+                       private static final long serialVersionUID = 1L;
+
+                       @SuppressWarnings("unchecked")
+                       @Override
+                       public <C> IConverter<C> getConverter(Class<C> type)
+                       {
+                               if (Integer.class.isAssignableFrom(type))
+                               {
+                                       return (IConverter<C>)MINUTES_CONVERTER;
+                               }
+                               else
+                               {
+                                       return super.getConverter(type);
+                               }
+                       }
+               };
+               minutesField.add(new RangeValidator<>(0, 59));
+               minutesField.setLabel(new Model<>(MINUTES));
+               return minutesField;
+       }
+
+       /**
         * 
         * @return The date TextField
         */

Reply via email to