You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2008/04/16 20:21:52 UTC

svn commit: r648780 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/ theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/

Author: bommel
Date: Wed Apr 16 11:21:50 2008
New Revision: 648780

URL: http://svn.apache.org/viewvc?rev=648780&view=rev
Log:
(TOBAGO-647) Setting the converter of the timeInput in the datePicker depending on the supplied date and time pattern

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java?rev=648780&r1=648779&r2=648780&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java Wed Apr 16 11:21:50 2008
@@ -120,7 +120,6 @@
   public static final String ATTR_POPUP_LIST = "popupList";
   public static final String ATTR_RENDERED_PARTIALLY = "renderedPartially";
   public static final String ATTR_POPUP_RESET = "popupReset";
-  public static final String ATTR_POPUP_CALENDAR_FORCE_TIME = "popupCalendarForceTime";
   public static final String ATTR_POPUP_CALENDAR_ID = "popupCalendarId";
   public static final String ATTR_PREFORMATED = "preformated";
   public static final String ATTR_READONLY = "readonly";

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java?rev=648780&r1=648779&r2=648780&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java Wed Apr 16 11:21:50 2008
@@ -24,12 +24,12 @@
 import static org.apache.myfaces.tobago.TobagoConstants.FACET_PICKER_POPUP;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_POPUP_RESET;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_HEIGHT;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_POPUP_CALENDAR_FORCE_TIME;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_WIDTH;
 import org.apache.myfaces.tobago.component.UIDatePicker;
 import org.apache.myfaces.tobago.component.UIPopup;
 import org.apache.myfaces.tobago.component.UIDateInput;
 import org.apache.myfaces.tobago.component.AbstractUIPage;
+import org.apache.myfaces.tobago.component.UITimeInput;
 import org.apache.myfaces.tobago.util.ComponentUtil;
 import org.apache.myfaces.tobago.config.ThemeConfig;
 import org.apache.myfaces.tobago.util.DateFormatUtils;
@@ -43,8 +43,10 @@
 import javax.faces.component.UICommand;
 import javax.faces.convert.Converter;
 import javax.faces.convert.DateTimeConverter;
+import static javax.faces.convert.DateTimeConverter.CONVERTER_ID;
 import java.io.IOException;
 import java.util.Map;
+import java.util.TimeZone;
 
 /*
  * Date: 30.05.2006
@@ -111,7 +113,7 @@
     attributes.put(TobagoConstants.ATTR_POPUP_CLOSE, "immediate");
     //cancelButton.setActionListener(datePickerController);
 
-    applyConverterPattern(popup, converterPattern);
+    applyConverterPattern(facesContext, popup, converterPattern);
 
     if (popup != null) {
       AbstractUIPage page = ComponentUtil.findPage(facesContext, link);
@@ -123,17 +125,23 @@
     super.encodeBegin(facesContext, component);
   }
 
-  private void applyConverterPattern(UIPopup popup, String converterPattern) {
+  private void applyConverterPattern(FacesContext facesContext, UIPopup popup, String converterPattern) {
     UIComponent box = (UIComponent) popup.getChildren().get(0);
     UIComponent timePanel = box.findComponent("timePanel");
     if (converterPattern != null && (converterPattern.indexOf('h') > -1 || converterPattern.indexOf('H') > -1)) {
+      UIComponent time = timePanel.findComponent("time");
+      int popupHeight = ComponentUtil.getIntAttribute(popup, ATTR_HEIGHT);
+      popupHeight += ThemeConfig.getValue(FacesContext.getCurrentInstance(), time, "fixedHeight");
+      popup.getAttributes().put(ATTR_HEIGHT, popupHeight);
+      DateTimeConverter dateTimeConverter
+             = (DateTimeConverter) facesContext.getApplication().createConverter(CONVERTER_ID);
       if (converterPattern.indexOf('s') > -1) {
-        UIComponent time = timePanel.findComponent("time");
-        int popupHeight = ComponentUtil.getIntAttribute(popup, ATTR_HEIGHT);
-        popupHeight += ThemeConfig.getValue(FacesContext.getCurrentInstance(), time, "fixedHeight");
-        popup.getAttributes().put(ATTR_HEIGHT, popupHeight);
-        time.getAttributes().put(ATTR_POPUP_CALENDAR_FORCE_TIME, true);
+        dateTimeConverter.setPattern("HH:mm:ss");
+      } else {
+        dateTimeConverter.setPattern("HH:mm");
       }
+      dateTimeConverter.setTimeZone(TimeZone.getDefault());
+      ((UITimeInput) time).setConverter(dateTimeConverter);
     } else {
       timePanel.setRendered(false);
     }

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java?rev=648780&r1=648779&r2=648780&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java Wed Apr 16 11:21:50 2008
@@ -26,7 +26,6 @@
 import org.apache.commons.logging.LogFactory;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_CALENDAR_DATE_INPUT_ID;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_POPUP_CALENDAR_FORCE_TIME;
 import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_READONLY;
 import org.apache.myfaces.tobago.util.ComponentUtil;
@@ -86,8 +85,6 @@
           converterPattern += ":ss";
         }
       }
-    } else if (ComponentUtil.getBooleanAttribute(input, ATTR_POPUP_CALENDAR_FORCE_TIME)) {
-      converterPattern += ":ss";
     }
 
     boolean hasSeconds = converterPattern.indexOf('s') > -1;