FAQ
Author: lofwyr
Date: Fri Jun 10 14:38:00 2016
New Revision: 1747723

URL: http://svn.apache.org/viewvc?rev=1747723&view=rev
Log:
TOBAGO 1483 Let tc date use a Bootstrap component as picker
* fix picker, if there is no converter defined.
* add a default converter for java.util.Date

Modified:
     myfaces/tobago/trunk/tobago-core/src/main/faces-config/faces-config.xml
     myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java
     myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/DateTagDeclaration.java
     myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/DateFormatUtils.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/faces-config/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/faces-config/faces-config.xml?rev=1747723&r1=1747722&r2=1747723&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/faces-config/faces-config.xml (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/faces-config/faces-config.xml Fri Jun 10 14:38:00 2016
@@ -43,12 +43,16 @@
      <component-class>org.apache.myfaces.tobago.component.UIMenuSelectOne</component-class>
    </component>

+ <converter>
+ <converter-for-class>java.util.Date</converter-for-class>
+ <converter-class>javax.faces.convert.DateTimeConverter</converter-class>
+ </converter>
+
    <managed-bean>
      <managed-bean-name>tobagoClientProperties</managed-bean-name>
      <managed-bean-class>org.apache.myfaces.tobago.context.ClientProperties</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
-
    <managed-bean>
      <managed-bean-name>tobagoContext</managed-bean-name>
      <managed-bean-class>org.apache.myfaces.tobago.context.TobagoContext</managed-bean-class>

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java?rev=1747723&r1=1747722&r2=1747723&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java Fri Jun 10 14:38:00 2016
@@ -20,9 +20,11 @@
  package org.apache.myfaces.tobago.internal.component;

  import org.apache.myfaces.tobago.internal.util.DateFormatUtils;
+import org.apache.myfaces.tobago.util.ComponentUtils;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;

+import javax.faces.context.FacesContext;
  import javax.faces.convert.Converter;
  import javax.faces.convert.DateTimeConverter;

@@ -32,15 +34,16 @@ public abstract class AbstractUIDate ext

    public String getPattern() {
      String pattern = null;
- final Converter help = getConverter();
- if (help instanceof DateTimeConverter) {
- final DateTimeConverter converter = (DateTimeConverter) help;
- pattern = DateFormatUtils.findPattern(converter);
+ final FacesContext facesContext = getFacesContext();
+ final Converter converter = ComponentUtils.getConverter(facesContext, this);
+ if (converter instanceof DateTimeConverter) {
+ pattern = DateFormatUtils.findPattern((DateTimeConverter) converter);
      }
      if (pattern == null) {
- pattern = "yyyy-MM-dd";
- LOG.warn("Can't find the pattern for the converter! DatePicker may not work correctly. "
- + "Trying to use: '" + pattern + "'");
+ if (LOG.isWarnEnabled()) {
+ LOG.warn("Can't find the pattern for the converter in component {}! DatePicker may not work correctly.",
+ getClientId(facesContext));
+ }
      }
      return pattern;
    }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/DateTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/DateTagDeclaration.java?rev=1747723&r1=1747722&r2=1747723&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/DateTagDeclaration.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/DateTagDeclaration.java Fri Jun 10 14:38:00 2016
@@ -48,8 +48,10 @@ import javax.faces.component.UIInput;

  /**
   * Renders a date input field.
- *
+ * <p>
   * For a time input field set you'll need to set the &lt;f:convertDateTime type="time"&gt; inside the &lt;tc:date&gt;.
+ * <p>
+ * If there is no converter given, a default instance of {@link javax.faces.convert.DateTimeConverter} will be used.
   */
  @Tag(name = "date")
  @UIComponentTag(
@@ -60,10 +62,10 @@ import javax.faces.component.UIInput;
      rendererType = RendererTypes.DATE,
      allowedChildComponenents = "NONE",
      facets = {
- @Facet(name = Facets.CHANGE,
- description =
- "This facet can contain a UICommand that is invoked in a case of a change event from the component")
- })
+ @Facet(name = Facets.CHANGE,
+ description =
+ "This facet can contain a UICommand that is invoked in a case of a change event from the component")
+ })
  public interface DateTagDeclaration
      extends HasAccessKey, HasValidator, HasValue, HasValueChangeListener, HasTabIndex, IsFocus, IsVisual,
      HasValidatorMessage, HasConverterMessage, HasRequiredMessage, HasIdBindingAndRendered, IsReadonly,

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/DateFormatUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/DateFormatUtils.java?rev=1747723&r1=1747722&r2=1747723&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/DateFormatUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/DateFormatUtils.java Fri Jun 10 14:38:00 2016
@@ -66,7 +66,7 @@ public final class DateFormatUtils {
      return pattern;
    }

- public static DateFormat getDateFormat(
+ private static DateFormat getDateFormat(
        final String type, final String dateStyle, final String timeStyle, final Locale locale) {
      final DateFormat format;
      if (type.equals(TYPE_DATE)) {

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categoriesmyfaces
postedJun 10, '16 at 2:38p
activeJun 10, '16 at 2:38p
posts1
users1
websitemyfaces.apache.org

1 user in discussion

Lofwyr: 1 post

People

Translate

site design / logo © 2019 Grokbase