You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-dev@incubator.apache.org by Adam Winer <aw...@gmail.com> on 2007/01/10 17:03:54 UTC

Re: svn commit: r494818 - in /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main: java/org/apache/myfaces/trinidadinternal/convert/ javascript/META-INF/adf/jsLibs/

Matthias,

Could you provide more detailed logs than "some converter work"?
It'd help for knowing what's up with the project - and, if a bug
gets in, very helpful for looking through the log and figuring out what
might have triggered the problem.

-- Adam


On 1/10/07, matzew@apache.org <ma...@apache.org> wrote:
> Author: matzew
> Date: Wed Jan 10 06:06:22 2007
> New Revision: 494818
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=494818
> Log:
> some converter works
>
> Modified:
>     incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java
>     incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java
>     incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
>     incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
>
> Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java
> URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java?view=diff&rev=494818&r1=494817&r2=494818
> ==============================================================================
> --- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java (original)
> +++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java Wed Jan 10 06:06:22 2007
> @@ -15,20 +15,21 @@
>   */
>  package org.apache.myfaces.trinidadinternal.convert;
>
> +import java.io.IOException;
>  import java.util.Collection;
>  import java.util.Collections;
> +import java.util.HashMap;
>  import java.util.Map;
>
> -import javax.faces.application.FacesMessage;
>  import javax.faces.component.UIComponent;
>  import javax.faces.context.FacesContext;
>
>  import org.apache.myfaces.trinidad.convert.ClientConverter;
>  import org.apache.myfaces.trinidad.logging.TrinidadLogger;
> -import org.apache.myfaces.trinidad.util.MessageFactory;
>  import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlUtils;
>  import org.apache.myfaces.trinidadinternal.share.text.RGBColorFormat;
>  import org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.XhtmlLafUtils;
> +import org.apache.myfaces.trinidadinternal.util.JsonUtils;
>
>  /**
>   * @author The Oracle ADF Faces Team
> @@ -139,10 +140,7 @@
>     */
>    public String getClientConversion(FacesContext context, UIComponent component)
>    {
> -    int patternsArgSize = _getPatternsArgSize();
> -
> -    int size = 19 + patternsArgSize + 19;
> -    StringBuilder sb = new StringBuilder(size);
> +    StringBuilder sb = new StringBuilder();
>
>      StringBuilder patterns = new StringBuilder();
>      String[] setPatterns = getPatterns();
> @@ -168,25 +166,35 @@
>
>      sb.append(XhtmlLafUtils.escapeJS(patternsString));
>
> +    Map<String, String> messages = new HashMap<String, String>();
>
>      String convMsgDet = getMessageDetailConvert();
>      if(convMsgDet != null)
>      {
> -      Object[] params = new Object[] {"{0}", "{1}", "{2}"};
> -
> -      FacesMessage msg = MessageFactory.getMessage(context, CONVERT_MESSAGE_ID,
> -                                             convMsgDet, params);
> -
> -      sb.append("','");
> -      sb.append(XhtmlLafUtils.escapeJS(msg.getDetail()));
> +      messages.put("detail", convMsgDet);
>      }
> +
> +    String hint = getHintFormat();
>
> -    sb.append("')");
> +    if(hint != null)
> +    {
> +      messages.put("hint", hint);
> +    }
> +
> +    sb.append("',");
> +    try
> +    {
> +      JsonUtils.writeMap(sb, messages, false);
> +    }
> +    catch (IOException e)
> +    {
> +      sb.append("null");
> +    }
> +    sb.append(')');
>
>      return sb.toString();
>    }
>
> -
>    public int getColumns(
>      FacesContext context)
>    {
> @@ -200,26 +208,6 @@
>        columns = Math.max(columns, new RGBColorFormat(patterns[i]).length());
>
>      return columns;
> -  }
> -
> -  // Returns the length of the patterns argument
> -  private int _getPatternsArgSize()
> -  {
> -    String[] patterns = this.getPatterns();
> -    int count = patterns.length;
> -
> -    if (count == 1)
> -      return patterns[0].length();
> -
> -    int size = 11; // Leave room for "new Array()"
> -
> -    for (int i = 0; i < count; i++)
> -    {
> -      // Include room for the pattern, comma, and quotes
> -      size += (patterns[i].length() + 3);
> -    }
> -
> -    return size;
>    }
>
>    // Appends the patterns argument to the StringBuilder
>
> Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java
> URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java?view=diff&rev=494818&r1=494817&r2=494818
> ==============================================================================
> --- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java (original)
> +++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java Wed Jan 10 06:06:22 2007
> @@ -15,11 +15,13 @@
>   */
>  package org.apache.myfaces.trinidadinternal.convert;
>
> +import java.io.IOException;
>  import java.text.DateFormat;
>  import java.text.SimpleDateFormat;
>  import java.util.Collection;
>  import java.util.Collections;
>  import java.util.Date;
> +import java.util.HashMap;
>  import java.util.Locale;
>  import java.util.Map;
>  import java.util.TimeZone;
> @@ -38,6 +40,7 @@
>  import org.apache.myfaces.trinidad.util.MessageFactory;
>  import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlUtils;
>  import org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.XhtmlLafUtils;
> +import org.apache.myfaces.trinidadinternal.util.JsonUtils;
>
>  /**
>   * <p>
> @@ -206,7 +209,7 @@
>      }
>
>      String jsPattern = getJSPattern(context);
> -
> +    Map<String, String> messages = new HashMap<String, String>();
>      if (jsPattern != null)
>      {
>        String pattern = getPattern();
> @@ -221,37 +224,47 @@
>            "{0}", "{1}", "{2}"
>        };
>        Object msgPattern = getMessagePattern(context, key, params, component);
> +      String hintFormat = getHintFormat();
>
>        FacesMessage msg = null;
>        String detailMessage = null;
> -      int customMessages = 0;
> +
>        if (msgPattern != null)
>        {
>          msg = MessageFactory.getMessage(context, key, msgPattern, params,
>              component);
>          detailMessage = XhtmlLafUtils.escapeJS(msg.getDetail());
> -        customMessages = 6 + detailMessage.length();
> -
>        }
> +
>        String exampleString = XhtmlLafUtils.escapeJS(getExample(context));
>        String escapedType = XhtmlLafUtils.escapeJS(getType().toUpperCase());
>
> -      StringBuilder outBuffer = new StringBuilder(33 + jsPattern.length()
> -          + exampleString.length() + escapedType.length() + customMessages);
> -      outBuffer.append("new TrDateTimeConverter("); // 21
> -      outBuffer.append(jsPattern); // jsPattern.length
> -      outBuffer.append(",null,'"); // 7
> -      outBuffer.append(exampleString); // exampleString.length
> -      outBuffer.append("','"); // 3
> -      outBuffer.append(escapedType); // escapedKey.length
> +      StringBuilder outBuffer = new StringBuilder();
> +      outBuffer.append("new TrDateTimeConverter(");
> +      outBuffer.append(jsPattern);
> +      outBuffer.append(",null,'");
> +      outBuffer.append(exampleString);
> +      outBuffer.append("','");
> +      outBuffer.append(escapedType);
> +      outBuffer.append("'");
>
> -      if (msgPattern != null)
> +      if (msgPattern != null || hintFormat != null)
>        {
> -        outBuffer.append("','"); // 3
> -        outBuffer.append(detailMessage); // detail message.length/
> +        messages.put("detail", detailMessage);
> +        messages.put("hint", hintFormat);
> +        outBuffer.append(',');
> +
> +        try
> +        {
> +          JsonUtils.writeMap(outBuffer, messages, false);
> +        }
> +        catch (IOException e)
> +        {
> +          outBuffer.append("null");
> +        }
>        }
>
> -      outBuffer.append("')"); // 2
> +      outBuffer.append(')'); // 2
>
>        return outBuffer.toString();
>      } else
>
> Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
> URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js?view=diff&rev=494818&r1=494817&r2=494818
> ==============================================================================
> --- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js (original)
> +++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js Wed Jan 10 06:06:22 2007
> @@ -21,13 +21,13 @@
>    pattern,
>    allowsTransparent,
>    patternsString,
> -  detail)
> +  messages)
>  {
>    // for debugging
>    this._class = "TrColorConverter";
>    this._allowsTransparent = allowsTransparent;
>    this._patternsString = patternsString;
> -  this._detail = detail;
> +  this._messages = messages;
>
>    if (pattern != null)
>    {
> @@ -42,9 +42,18 @@
>
>  TrColorConverter.prototype.getFormatHint = function()
>  {
> -       return TrMessageFactory.createMessage(
> -    "org.apache.myfaces.trinidad.convert.ColorConverter.FORMAT_HINT",
> -         this._pattern);
> +       if(this._messages && this._messages["hint"])
> +       {
> +    return TrMessageFactory.createCustomMessage(
> +      this._messages["hint"],
> +      this._pattern);
> +       }
> +       else
> +       {
> +    return TrMessageFactory.createMessage(
> +      "org.apache.myfaces.trinidad.convert.ColorConverter.FORMAT_HINT",
> +      this._pattern);
> +       }
>  }
>  TrColorConverter.prototype.getAsString = function(
>    formatColor)
> @@ -96,18 +105,18 @@
>
>    var facesMessage;
>    var key = "org.apache.myfaces.trinidad.convert.ColorConverter.CONVERT";
> -  if(this._detail == undefined)
> +  if(this._messages && this._messages["detail"])
>    {
> -    facesMessage = _createFacesMessage(key,
> +    facesMessage = _createCustomFacesMessage(
> +                                       TrMessageFactory.getSummaryString(key),
> +                                       this._messages["detail"],
>                                         label,
>                                         parseString,
>                                         this._patternsString);
>    }
>    else
>    {
> -    facesMessage = _createCustomFacesMessage(
> -                                       TrMessageFactory.getSummaryString(key),
> -                                       this._detail,
> +    facesMessage = _createFacesMessage(key,
>                                         label,
>                                         parseString,
>                                         this._patternsString);
>
> Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
> URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js?view=diff&rev=494818&r1=494817&r2=494818
> ==============================================================================
> --- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js (original)
> +++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js Wed Jan 10 06:06:22 2007
> @@ -1021,7 +1021,7 @@
>    locale,
>    exampleString,
>    type,
> -  detail
> +  messages
>    )
>  {
>
> @@ -1029,7 +1029,7 @@
>    this._class = "TrDateTimeConverter";
>    this._exampleString = exampleString;
>    this._type = type;
> -  this._detail = detail;
> +  this._messages = messages;
>    this._offset = null;
>
>    // save the Locale elements for the specified locale, or client locale
> @@ -1050,9 +1050,19 @@
>
>  TrDateTimeConverter.prototype.getFormatHint = function()
>  {
> -       return TrMessageFactory.createMessage(
> -    "org.apache.myfaces.trinidad.convert.DateTimeConverter.FORMAT_HINT",
> -    this._pattern);
> +       if(this._messages && this._messages["hint"])
> +       {
> +    return TrMessageFactory.createCustomMessage(
> +      this._messages["hint"],
> +      this._pattern);
> +
> +       }
> +       else
> +       {
> +    return TrMessageFactory.createMessage(
> +      "org.apache.myfaces.trinidad.convert.DateTimeConverter.FORMAT_HINT",
> +      this._pattern);
> +       }
>  }
>
>  TrDateTimeConverter.prototype.getAsString = function(
> @@ -1112,7 +1122,6 @@
>    label
>    )
>  {
> -
>    // The following are from the javadoc for DateTimeConverter
>    // If the specified String is null, return a null. Otherwise, trim leading and trailing whitespace before proceeding.
>    // If the specified String - after trimming - has a zero length, return null.
> @@ -1127,17 +1136,17 @@
>
>    var facesMessage;
>    var key = "org.apache.myfaces.trinidad.convert.DateTimeConverter.CONVERT_"+this._type;
> -  if(this._detail == undefined)
> +  if(this._messages && this._messages["detail"])
>    {
> -    facesMessage = _createFacesMessage( key,
> +    facesMessage = _createCustomFacesMessage(TrMessageFactory.getSummaryString(key),
> +                                          this._messages["detail"],
>                                            label,
>                                            parseString,
>                                            this._exampleString);
>    }
>    else
>    {
> -    facesMessage = _createCustomFacesMessage(TrMessageFactory.getSummaryString(key),
> -                                          this._detail,
> +    facesMessage = _createFacesMessage( key,
>                                            label,
>                                            parseString,
>                                            this._exampleString);
>
>
>

Re: svn commit: r494818 - in /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main: java/org/apache/myfaces/trinidadinternal/convert/ javascript/META-INF/adf/jsLibs/

Posted by Matthias Wessendorf <ma...@apache.org>.
in a good world we have only! commits which are nailed into Jira...
;)

On 1/10/07, Scott O'Bryan <da...@gmail.com> wrote:
> I liked the comment.  My portal changes should be commented as "some
> portal changes".  :)
>
> Matthias Wessendorf wrote:
> > usually I do, not here.however no bug involved.
> > clean up and enhancements:
> >
> > I changed some code on sending down the customized messageDetailXxxx.
> > I also provided a hook for a possible hint framework to customize the
> > hint.
> > all messages are now send down in a map.
> >
> > (same for the "some vali work" commit)
> >
> > -M
> >
> > On 1/10/07, Adam Winer <aw...@gmail.com> wrote:
> >> Matthias,
> >>
> >> Could you provide more detailed logs than "some converter work"?
> >> It'd help for knowing what's up with the project - and, if a bug
> >> gets in, very helpful for looking through the log and figuring out what
> >> might have triggered the problem.
> >>
> >> -- Adam
> >>
> >>
> >> On 1/10/07, matzew@apache.org <ma...@apache.org> wrote:
> >> > Author: matzew
> >> > Date: Wed Jan 10 06:06:22 2007
> >> > New Revision: 494818
> >> >
> >> > URL: http://svn.apache.org/viewvc?view=rev&rev=494818
> >> > Log:
> >> > some converter works
> >> >
> >> > Modified:
> >> >
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java
> >>
> >> >
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java
> >>
> >> >
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
> >>
> >> >
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
> >>
> >> >
> >> > Modified:
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java
> >>
> >> > URL:
> >> http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java?view=diff&rev=494818&r1=494817&r2=494818
> >>
> >> >
> >> ==============================================================================
> >>
> >> > ---
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java
> >> (original)
> >> > +++
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java
> >> Wed Jan 10 06:06:22 2007
> >> > @@ -15,20 +15,21 @@
> >> >   */
> >> >  package org.apache.myfaces.trinidadinternal.convert;
> >> >
> >> > +import java.io.IOException;
> >> >  import java.util.Collection;
> >> >  import java.util.Collections;
> >> > +import java.util.HashMap;
> >> >  import java.util.Map;
> >> >
> >> > -import javax.faces.application.FacesMessage;
> >> >  import javax.faces.component.UIComponent;
> >> >  import javax.faces.context.FacesContext;
> >> >
> >> >  import org.apache.myfaces.trinidad.convert.ClientConverter;
> >> >  import org.apache.myfaces.trinidad.logging.TrinidadLogger;
> >> > -import org.apache.myfaces.trinidad.util.MessageFactory;
> >> >  import
> >> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlUtils;
> >> >  import org.apache.myfaces.trinidadinternal.share.text.RGBColorFormat;
> >> >  import
> >> org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.XhtmlLafUtils;
> >> > +import org.apache.myfaces.trinidadinternal.util.JsonUtils;
> >> >
> >> >  /**
> >> >   * @author The Oracle ADF Faces Team
> >> > @@ -139,10 +140,7 @@
> >> >     */
> >> >    public String getClientConversion(FacesContext context,
> >> UIComponent component)
> >> >    {
> >> > -    int patternsArgSize = _getPatternsArgSize();
> >> > -
> >> > -    int size = 19 + patternsArgSize + 19;
> >> > -    StringBuilder sb = new StringBuilder(size);
> >> > +    StringBuilder sb = new StringBuilder();
> >> >
> >> >      StringBuilder patterns = new StringBuilder();
> >> >      String[] setPatterns = getPatterns();
> >> > @@ -168,25 +166,35 @@
> >> >
> >> >      sb.append(XhtmlLafUtils.escapeJS(patternsString));
> >> >
> >> > +    Map<String, String> messages = new HashMap<String, String>();
> >> >
> >> >      String convMsgDet = getMessageDetailConvert();
> >> >      if(convMsgDet != null)
> >> >      {
> >> > -      Object[] params = new Object[] {"{0}", "{1}", "{2}"};
> >> > -
> >> > -      FacesMessage msg = MessageFactory.getMessage(context,
> >> CONVERT_MESSAGE_ID,
> >> > -                                             convMsgDet, params);
> >> > -
> >> > -      sb.append("','");
> >> > -      sb.append(XhtmlLafUtils.escapeJS(msg.getDetail()));
> >> > +      messages.put("detail", convMsgDet);
> >> >      }
> >> > +
> >> > +    String hint = getHintFormat();
> >> >
> >> > -    sb.append("')");
> >> > +    if(hint != null)
> >> > +    {
> >> > +      messages.put("hint", hint);
> >> > +    }
> >> > +
> >> > +    sb.append("',");
> >> > +    try
> >> > +    {
> >> > +      JsonUtils.writeMap(sb, messages, false);
> >> > +    }
> >> > +    catch (IOException e)
> >> > +    {
> >> > +      sb.append("null");
> >> > +    }
> >> > +    sb.append(')');
> >> >
> >> >      return sb.toString();
> >> >    }
> >> >
> >> > -
> >> >    public int getColumns(
> >> >      FacesContext context)
> >> >    {
> >> > @@ -200,26 +208,6 @@
> >> >        columns = Math.max(columns, new
> >> RGBColorFormat(patterns[i]).length());
> >> >
> >> >      return columns;
> >> > -  }
> >> > -
> >> > -  // Returns the length of the patterns argument
> >> > -  private int _getPatternsArgSize()
> >> > -  {
> >> > -    String[] patterns = this.getPatterns();
> >> > -    int count = patterns.length;
> >> > -
> >> > -    if (count == 1)
> >> > -      return patterns[0].length();
> >> > -
> >> > -    int size = 11; // Leave room for "new Array()"
> >> > -
> >> > -    for (int i = 0; i < count; i++)
> >> > -    {
> >> > -      // Include room for the pattern, comma, and quotes
> >> > -      size += (patterns[i].length() + 3);
> >> > -    }
> >> > -
> >> > -    return size;
> >> >    }
> >> >
> >> >    // Appends the patterns argument to the StringBuilder
> >> >
> >> > Modified:
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java
> >>
> >> > URL:
> >> http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java?view=diff&rev=494818&r1=494817&r2=494818
> >>
> >> >
> >> ==============================================================================
> >>
> >> > ---
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java
> >> (original)
> >> > +++
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java
> >> Wed Jan 10 06:06:22 2007
> >> > @@ -15,11 +15,13 @@
> >> >   */
> >> >  package org.apache.myfaces.trinidadinternal.convert;
> >> >
> >> > +import java.io.IOException;
> >> >  import java.text.DateFormat;
> >> >  import java.text.SimpleDateFormat;
> >> >  import java.util.Collection;
> >> >  import java.util.Collections;
> >> >  import java.util.Date;
> >> > +import java.util.HashMap;
> >> >  import java.util.Locale;
> >> >  import java.util.Map;
> >> >  import java.util.TimeZone;
> >> > @@ -38,6 +40,7 @@
> >> >  import org.apache.myfaces.trinidad.util.MessageFactory;
> >> >  import
> >> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlUtils;
> >> >  import
> >> org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.XhtmlLafUtils;
> >> > +import org.apache.myfaces.trinidadinternal.util.JsonUtils;
> >> >
> >> >  /**
> >> >   * <p>
> >> > @@ -206,7 +209,7 @@
> >> >      }
> >> >
> >> >      String jsPattern = getJSPattern(context);
> >> > -
> >> > +    Map<String, String> messages = new HashMap<String, String>();
> >> >      if (jsPattern != null)
> >> >      {
> >> >        String pattern = getPattern();
> >> > @@ -221,37 +224,47 @@
> >> >            "{0}", "{1}", "{2}"
> >> >        };
> >> >        Object msgPattern = getMessagePattern(context, key, params,
> >> component);
> >> > +      String hintFormat = getHintFormat();
> >> >
> >> >        FacesMessage msg = null;
> >> >        String detailMessage = null;
> >> > -      int customMessages = 0;
> >> > +
> >> >        if (msgPattern != null)
> >> >        {
> >> >          msg = MessageFactory.getMessage(context, key, msgPattern,
> >> params,
> >> >              component);
> >> >          detailMessage = XhtmlLafUtils.escapeJS(msg.getDetail());
> >> > -        customMessages = 6 + detailMessage.length();
> >> > -
> >> >        }
> >> > +
> >> >        String exampleString =
> >> XhtmlLafUtils.escapeJS(getExample(context));
> >> >        String escapedType =
> >> XhtmlLafUtils.escapeJS(getType().toUpperCase());
> >> >
> >> > -      StringBuilder outBuffer = new StringBuilder(33 +
> >> jsPattern.length()
> >> > -          + exampleString.length() + escapedType.length() +
> >> customMessages);
> >> > -      outBuffer.append("new TrDateTimeConverter("); // 21
> >> > -      outBuffer.append(jsPattern); // jsPattern.length
> >> > -      outBuffer.append(",null,'"); // 7
> >> > -      outBuffer.append(exampleString); // exampleString.length
> >> > -      outBuffer.append("','"); // 3
> >> > -      outBuffer.append(escapedType); // escapedKey.length
> >> > +      StringBuilder outBuffer = new StringBuilder();
> >> > +      outBuffer.append("new TrDateTimeConverter(");
> >> > +      outBuffer.append(jsPattern);
> >> > +      outBuffer.append(",null,'");
> >> > +      outBuffer.append(exampleString);
> >> > +      outBuffer.append("','");
> >> > +      outBuffer.append(escapedType);
> >> > +      outBuffer.append("'");
> >> >
> >> > -      if (msgPattern != null)
> >> > +      if (msgPattern != null || hintFormat != null)
> >> >        {
> >> > -        outBuffer.append("','"); // 3
> >> > -        outBuffer.append(detailMessage); // detail message.length/
> >> > +        messages.put("detail", detailMessage);
> >> > +        messages.put("hint", hintFormat);
> >> > +        outBuffer.append(',');
> >> > +
> >> > +        try
> >> > +        {
> >> > +          JsonUtils.writeMap(outBuffer, messages, false);
> >> > +        }
> >> > +        catch (IOException e)
> >> > +        {
> >> > +          outBuffer.append("null");
> >> > +        }
> >> >        }
> >> >
> >> > -      outBuffer.append("')"); // 2
> >> > +      outBuffer.append(')'); // 2
> >> >
> >> >        return outBuffer.toString();
> >> >      } else
> >> >
> >> > Modified:
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
> >>
> >> > URL:
> >> http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js?view=diff&rev=494818&r1=494817&r2=494818
> >>
> >> >
> >> ==============================================================================
> >>
> >> > ---
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
> >> (original)
> >> > +++
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
> >> Wed Jan 10 06:06:22 2007
> >> > @@ -21,13 +21,13 @@
> >> >    pattern,
> >> >    allowsTransparent,
> >> >    patternsString,
> >> > -  detail)
> >> > +  messages)
> >> >  {
> >> >    // for debugging
> >> >    this._class = "TrColorConverter";
> >> >    this._allowsTransparent = allowsTransparent;
> >> >    this._patternsString = patternsString;
> >> > -  this._detail = detail;
> >> > +  this._messages = messages;
> >> >
> >> >    if (pattern != null)
> >> >    {
> >> > @@ -42,9 +42,18 @@
> >> >
> >> >  TrColorConverter.prototype.getFormatHint = function()
> >> >  {
> >> > -       return TrMessageFactory.createMessage(
> >> > -    "org.apache.myfaces.trinidad.convert.ColorConverter.FORMAT_HINT",
> >> > -         this._pattern);
> >> > +       if(this._messages && this._messages["hint"])
> >> > +       {
> >> > +    return TrMessageFactory.createCustomMessage(
> >> > +      this._messages["hint"],
> >> > +      this._pattern);
> >> > +       }
> >> > +       else
> >> > +       {
> >> > +    return TrMessageFactory.createMessage(
> >> > +
> >> "org.apache.myfaces.trinidad.convert.ColorConverter.FORMAT_HINT",
> >> > +      this._pattern);
> >> > +       }
> >> >  }
> >> >  TrColorConverter.prototype.getAsString = function(
> >> >    formatColor)
> >> > @@ -96,18 +105,18 @@
> >> >
> >> >    var facesMessage;
> >> >    var key =
> >> "org.apache.myfaces.trinidad.convert.ColorConverter.CONVERT";
> >> > -  if(this._detail == undefined)
> >> > +  if(this._messages && this._messages["detail"])
> >> >    {
> >> > -    facesMessage = _createFacesMessage(key,
> >> > +    facesMessage = _createCustomFacesMessage(
> >> > +
> >> TrMessageFactory.getSummaryString(key),
> >> > +                                       this._messages["detail"],
> >> >                                         label,
> >> >                                         parseString,
> >> >                                         this._patternsString);
> >> >    }
> >> >    else
> >> >    {
> >> > -    facesMessage = _createCustomFacesMessage(
> >> > -
> >> TrMessageFactory.getSummaryString(key),
> >> > -                                       this._detail,
> >> > +    facesMessage = _createFacesMessage(key,
> >> >                                         label,
> >> >                                         parseString,
> >> >                                         this._patternsString);
> >> >
> >> > Modified:
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
> >>
> >> > URL:
> >> http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js?view=diff&rev=494818&r1=494817&r2=494818
> >>
> >> >
> >> ==============================================================================
> >>
> >> > ---
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
> >> (original)
> >> > +++
> >> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
> >> Wed Jan 10 06:06:22 2007
> >> > @@ -1021,7 +1021,7 @@
> >> >    locale,
> >> >    exampleString,
> >> >    type,
> >> > -  detail
> >> > +  messages
> >> >    )
> >> >  {
> >> >
> >> > @@ -1029,7 +1029,7 @@
> >> >    this._class = "TrDateTimeConverter";
> >> >    this._exampleString = exampleString;
> >> >    this._type = type;
> >> > -  this._detail = detail;
> >> > +  this._messages = messages;
> >> >    this._offset = null;
> >> >
> >> >    // save the Locale elements for the specified locale, or client
> >> locale
> >> > @@ -1050,9 +1050,19 @@
> >> >
> >> >  TrDateTimeConverter.prototype.getFormatHint = function()
> >> >  {
> >> > -       return TrMessageFactory.createMessage(
> >> > -
> >> "org.apache.myfaces.trinidad.convert.DateTimeConverter.FORMAT_HINT",
> >> > -    this._pattern);
> >> > +       if(this._messages && this._messages["hint"])
> >> > +       {
> >> > +    return TrMessageFactory.createCustomMessage(
> >> > +      this._messages["hint"],
> >> > +      this._pattern);
> >> > +
> >> > +       }
> >> > +       else
> >> > +       {
> >> > +    return TrMessageFactory.createMessage(
> >> > +
> >> "org.apache.myfaces.trinidad.convert.DateTimeConverter.FORMAT_HINT",
> >> > +      this._pattern);
> >> > +       }
> >> >  }
> >> >
> >> >  TrDateTimeConverter.prototype.getAsString = function(
> >> > @@ -1112,7 +1122,6 @@
> >> >    label
> >> >    )
> >> >  {
> >> > -
> >> >    // The following are from the javadoc for DateTimeConverter
> >> >    // If the specified String is null, return a null. Otherwise,
> >> trim leading and trailing whitespace before proceeding.
> >> >    // If the specified String - after trimming - has a zero length,
> >> return null.
> >> > @@ -1127,17 +1136,17 @@
> >> >
> >> >    var facesMessage;
> >> >    var key =
> >> "org.apache.myfaces.trinidad.convert.DateTimeConverter.CONVERT_"+this._type;
> >>
> >> > -  if(this._detail == undefined)
> >> > +  if(this._messages && this._messages["detail"])
> >> >    {
> >> > -    facesMessage = _createFacesMessage( key,
> >> > +    facesMessage =
> >> _createCustomFacesMessage(TrMessageFactory.getSummaryString(key),
> >> > +                                          this._messages["detail"],
> >> >                                            label,
> >> >                                            parseString,
> >> >                                            this._exampleString);
> >> >    }
> >> >    else
> >> >    {
> >> > -    facesMessage =
> >> _createCustomFacesMessage(TrMessageFactory.getSummaryString(key),
> >> > -                                          this._detail,
> >> > +    facesMessage = _createFacesMessage( key,
> >> >                                            label,
> >> >                                            parseString,
> >> >                                            this._exampleString);
> >> >
> >> >
> >> >
> >>
> >
> >
>
>


-- 
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Re: svn commit: r494818 - in /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main: java/org/apache/myfaces/trinidadinternal/convert/ javascript/META-INF/adf/jsLibs/

Posted by Scott O'Bryan <da...@gmail.com>.
I liked the comment.  My portal changes should be commented as "some 
portal changes".  :)

Matthias Wessendorf wrote:
> usually I do, not here.however no bug involved.
> clean up and enhancements:
>
> I changed some code on sending down the customized messageDetailXxxx.
> I also provided a hook for a possible hint framework to customize the 
> hint.
> all messages are now send down in a map.
>
> (same for the "some vali work" commit)
>
> -M
>
> On 1/10/07, Adam Winer <aw...@gmail.com> wrote:
>> Matthias,
>>
>> Could you provide more detailed logs than "some converter work"?
>> It'd help for knowing what's up with the project - and, if a bug
>> gets in, very helpful for looking through the log and figuring out what
>> might have triggered the problem.
>>
>> -- Adam
>>
>>
>> On 1/10/07, matzew@apache.org <ma...@apache.org> wrote:
>> > Author: matzew
>> > Date: Wed Jan 10 06:06:22 2007
>> > New Revision: 494818
>> >
>> > URL: http://svn.apache.org/viewvc?view=rev&rev=494818
>> > Log:
>> > some converter works
>> >
>> > Modified:
>> >     
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java 
>>
>> >     
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java 
>>
>> >     
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js 
>>
>> >     
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js 
>>
>> >
>> > Modified: 
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java 
>>
>> > URL: 
>> http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java?view=diff&rev=494818&r1=494817&r2=494818 
>>
>> > 
>> ============================================================================== 
>>
>> > --- 
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java 
>> (original)
>> > +++ 
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java 
>> Wed Jan 10 06:06:22 2007
>> > @@ -15,20 +15,21 @@
>> >   */
>> >  package org.apache.myfaces.trinidadinternal.convert;
>> >
>> > +import java.io.IOException;
>> >  import java.util.Collection;
>> >  import java.util.Collections;
>> > +import java.util.HashMap;
>> >  import java.util.Map;
>> >
>> > -import javax.faces.application.FacesMessage;
>> >  import javax.faces.component.UIComponent;
>> >  import javax.faces.context.FacesContext;
>> >
>> >  import org.apache.myfaces.trinidad.convert.ClientConverter;
>> >  import org.apache.myfaces.trinidad.logging.TrinidadLogger;
>> > -import org.apache.myfaces.trinidad.util.MessageFactory;
>> >  import 
>> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlUtils;
>> >  import org.apache.myfaces.trinidadinternal.share.text.RGBColorFormat;
>> >  import 
>> org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.XhtmlLafUtils;
>> > +import org.apache.myfaces.trinidadinternal.util.JsonUtils;
>> >
>> >  /**
>> >   * @author The Oracle ADF Faces Team
>> > @@ -139,10 +140,7 @@
>> >     */
>> >    public String getClientConversion(FacesContext context, 
>> UIComponent component)
>> >    {
>> > -    int patternsArgSize = _getPatternsArgSize();
>> > -
>> > -    int size = 19 + patternsArgSize + 19;
>> > -    StringBuilder sb = new StringBuilder(size);
>> > +    StringBuilder sb = new StringBuilder();
>> >
>> >      StringBuilder patterns = new StringBuilder();
>> >      String[] setPatterns = getPatterns();
>> > @@ -168,25 +166,35 @@
>> >
>> >      sb.append(XhtmlLafUtils.escapeJS(patternsString));
>> >
>> > +    Map<String, String> messages = new HashMap<String, String>();
>> >
>> >      String convMsgDet = getMessageDetailConvert();
>> >      if(convMsgDet != null)
>> >      {
>> > -      Object[] params = new Object[] {"{0}", "{1}", "{2}"};
>> > -
>> > -      FacesMessage msg = MessageFactory.getMessage(context, 
>> CONVERT_MESSAGE_ID,
>> > -                                             convMsgDet, params);
>> > -
>> > -      sb.append("','");
>> > -      sb.append(XhtmlLafUtils.escapeJS(msg.getDetail()));
>> > +      messages.put("detail", convMsgDet);
>> >      }
>> > +
>> > +    String hint = getHintFormat();
>> >
>> > -    sb.append("')");
>> > +    if(hint != null)
>> > +    {
>> > +      messages.put("hint", hint);
>> > +    }
>> > +
>> > +    sb.append("',");
>> > +    try
>> > +    {
>> > +      JsonUtils.writeMap(sb, messages, false);
>> > +    }
>> > +    catch (IOException e)
>> > +    {
>> > +      sb.append("null");
>> > +    }
>> > +    sb.append(')');
>> >
>> >      return sb.toString();
>> >    }
>> >
>> > -
>> >    public int getColumns(
>> >      FacesContext context)
>> >    {
>> > @@ -200,26 +208,6 @@
>> >        columns = Math.max(columns, new 
>> RGBColorFormat(patterns[i]).length());
>> >
>> >      return columns;
>> > -  }
>> > -
>> > -  // Returns the length of the patterns argument
>> > -  private int _getPatternsArgSize()
>> > -  {
>> > -    String[] patterns = this.getPatterns();
>> > -    int count = patterns.length;
>> > -
>> > -    if (count == 1)
>> > -      return patterns[0].length();
>> > -
>> > -    int size = 11; // Leave room for "new Array()"
>> > -
>> > -    for (int i = 0; i < count; i++)
>> > -    {
>> > -      // Include room for the pattern, comma, and quotes
>> > -      size += (patterns[i].length() + 3);
>> > -    }
>> > -
>> > -    return size;
>> >    }
>> >
>> >    // Appends the patterns argument to the StringBuilder
>> >
>> > Modified: 
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java 
>>
>> > URL: 
>> http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java?view=diff&rev=494818&r1=494817&r2=494818 
>>
>> > 
>> ============================================================================== 
>>
>> > --- 
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java 
>> (original)
>> > +++ 
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java 
>> Wed Jan 10 06:06:22 2007
>> > @@ -15,11 +15,13 @@
>> >   */
>> >  package org.apache.myfaces.trinidadinternal.convert;
>> >
>> > +import java.io.IOException;
>> >  import java.text.DateFormat;
>> >  import java.text.SimpleDateFormat;
>> >  import java.util.Collection;
>> >  import java.util.Collections;
>> >  import java.util.Date;
>> > +import java.util.HashMap;
>> >  import java.util.Locale;
>> >  import java.util.Map;
>> >  import java.util.TimeZone;
>> > @@ -38,6 +40,7 @@
>> >  import org.apache.myfaces.trinidad.util.MessageFactory;
>> >  import 
>> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlUtils;
>> >  import 
>> org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.XhtmlLafUtils;
>> > +import org.apache.myfaces.trinidadinternal.util.JsonUtils;
>> >
>> >  /**
>> >   * <p>
>> > @@ -206,7 +209,7 @@
>> >      }
>> >
>> >      String jsPattern = getJSPattern(context);
>> > -
>> > +    Map<String, String> messages = new HashMap<String, String>();
>> >      if (jsPattern != null)
>> >      {
>> >        String pattern = getPattern();
>> > @@ -221,37 +224,47 @@
>> >            "{0}", "{1}", "{2}"
>> >        };
>> >        Object msgPattern = getMessagePattern(context, key, params, 
>> component);
>> > +      String hintFormat = getHintFormat();
>> >
>> >        FacesMessage msg = null;
>> >        String detailMessage = null;
>> > -      int customMessages = 0;
>> > +
>> >        if (msgPattern != null)
>> >        {
>> >          msg = MessageFactory.getMessage(context, key, msgPattern, 
>> params,
>> >              component);
>> >          detailMessage = XhtmlLafUtils.escapeJS(msg.getDetail());
>> > -        customMessages = 6 + detailMessage.length();
>> > -
>> >        }
>> > +
>> >        String exampleString = 
>> XhtmlLafUtils.escapeJS(getExample(context));
>> >        String escapedType = 
>> XhtmlLafUtils.escapeJS(getType().toUpperCase());
>> >
>> > -      StringBuilder outBuffer = new StringBuilder(33 + 
>> jsPattern.length()
>> > -          + exampleString.length() + escapedType.length() + 
>> customMessages);
>> > -      outBuffer.append("new TrDateTimeConverter("); // 21
>> > -      outBuffer.append(jsPattern); // jsPattern.length
>> > -      outBuffer.append(",null,'"); // 7
>> > -      outBuffer.append(exampleString); // exampleString.length
>> > -      outBuffer.append("','"); // 3
>> > -      outBuffer.append(escapedType); // escapedKey.length
>> > +      StringBuilder outBuffer = new StringBuilder();
>> > +      outBuffer.append("new TrDateTimeConverter(");
>> > +      outBuffer.append(jsPattern);
>> > +      outBuffer.append(",null,'");
>> > +      outBuffer.append(exampleString);
>> > +      outBuffer.append("','");
>> > +      outBuffer.append(escapedType);
>> > +      outBuffer.append("'");
>> >
>> > -      if (msgPattern != null)
>> > +      if (msgPattern != null || hintFormat != null)
>> >        {
>> > -        outBuffer.append("','"); // 3
>> > -        outBuffer.append(detailMessage); // detail message.length/
>> > +        messages.put("detail", detailMessage);
>> > +        messages.put("hint", hintFormat);
>> > +        outBuffer.append(',');
>> > +
>> > +        try
>> > +        {
>> > +          JsonUtils.writeMap(outBuffer, messages, false);
>> > +        }
>> > +        catch (IOException e)
>> > +        {
>> > +          outBuffer.append("null");
>> > +        }
>> >        }
>> >
>> > -      outBuffer.append("')"); // 2
>> > +      outBuffer.append(')'); // 2
>> >
>> >        return outBuffer.toString();
>> >      } else
>> >
>> > Modified: 
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js 
>>
>> > URL: 
>> http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js?view=diff&rev=494818&r1=494817&r2=494818 
>>
>> > 
>> ============================================================================== 
>>
>> > --- 
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js 
>> (original)
>> > +++ 
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js 
>> Wed Jan 10 06:06:22 2007
>> > @@ -21,13 +21,13 @@
>> >    pattern,
>> >    allowsTransparent,
>> >    patternsString,
>> > -  detail)
>> > +  messages)
>> >  {
>> >    // for debugging
>> >    this._class = "TrColorConverter";
>> >    this._allowsTransparent = allowsTransparent;
>> >    this._patternsString = patternsString;
>> > -  this._detail = detail;
>> > +  this._messages = messages;
>> >
>> >    if (pattern != null)
>> >    {
>> > @@ -42,9 +42,18 @@
>> >
>> >  TrColorConverter.prototype.getFormatHint = function()
>> >  {
>> > -       return TrMessageFactory.createMessage(
>> > -    "org.apache.myfaces.trinidad.convert.ColorConverter.FORMAT_HINT",
>> > -         this._pattern);
>> > +       if(this._messages && this._messages["hint"])
>> > +       {
>> > +    return TrMessageFactory.createCustomMessage(
>> > +      this._messages["hint"],
>> > +      this._pattern);
>> > +       }
>> > +       else
>> > +       {
>> > +    return TrMessageFactory.createMessage(
>> > +      
>> "org.apache.myfaces.trinidad.convert.ColorConverter.FORMAT_HINT",
>> > +      this._pattern);
>> > +       }
>> >  }
>> >  TrColorConverter.prototype.getAsString = function(
>> >    formatColor)
>> > @@ -96,18 +105,18 @@
>> >
>> >    var facesMessage;
>> >    var key = 
>> "org.apache.myfaces.trinidad.convert.ColorConverter.CONVERT";
>> > -  if(this._detail == undefined)
>> > +  if(this._messages && this._messages["detail"])
>> >    {
>> > -    facesMessage = _createFacesMessage(key,
>> > +    facesMessage = _createCustomFacesMessage(
>> > +                                       
>> TrMessageFactory.getSummaryString(key),
>> > +                                       this._messages["detail"],
>> >                                         label,
>> >                                         parseString,
>> >                                         this._patternsString);
>> >    }
>> >    else
>> >    {
>> > -    facesMessage = _createCustomFacesMessage(
>> > -                                       
>> TrMessageFactory.getSummaryString(key),
>> > -                                       this._detail,
>> > +    facesMessage = _createFacesMessage(key,
>> >                                         label,
>> >                                         parseString,
>> >                                         this._patternsString);
>> >
>> > Modified: 
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js 
>>
>> > URL: 
>> http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js?view=diff&rev=494818&r1=494817&r2=494818 
>>
>> > 
>> ============================================================================== 
>>
>> > --- 
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js 
>> (original)
>> > +++ 
>> incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js 
>> Wed Jan 10 06:06:22 2007
>> > @@ -1021,7 +1021,7 @@
>> >    locale,
>> >    exampleString,
>> >    type,
>> > -  detail
>> > +  messages
>> >    )
>> >  {
>> >
>> > @@ -1029,7 +1029,7 @@
>> >    this._class = "TrDateTimeConverter";
>> >    this._exampleString = exampleString;
>> >    this._type = type;
>> > -  this._detail = detail;
>> > +  this._messages = messages;
>> >    this._offset = null;
>> >
>> >    // save the Locale elements for the specified locale, or client 
>> locale
>> > @@ -1050,9 +1050,19 @@
>> >
>> >  TrDateTimeConverter.prototype.getFormatHint = function()
>> >  {
>> > -       return TrMessageFactory.createMessage(
>> > -    
>> "org.apache.myfaces.trinidad.convert.DateTimeConverter.FORMAT_HINT",
>> > -    this._pattern);
>> > +       if(this._messages && this._messages["hint"])
>> > +       {
>> > +    return TrMessageFactory.createCustomMessage(
>> > +      this._messages["hint"],
>> > +      this._pattern);
>> > +
>> > +       }
>> > +       else
>> > +       {
>> > +    return TrMessageFactory.createMessage(
>> > +      
>> "org.apache.myfaces.trinidad.convert.DateTimeConverter.FORMAT_HINT",
>> > +      this._pattern);
>> > +       }
>> >  }
>> >
>> >  TrDateTimeConverter.prototype.getAsString = function(
>> > @@ -1112,7 +1122,6 @@
>> >    label
>> >    )
>> >  {
>> > -
>> >    // The following are from the javadoc for DateTimeConverter
>> >    // If the specified String is null, return a null. Otherwise, 
>> trim leading and trailing whitespace before proceeding.
>> >    // If the specified String - after trimming - has a zero length, 
>> return null.
>> > @@ -1127,17 +1136,17 @@
>> >
>> >    var facesMessage;
>> >    var key = 
>> "org.apache.myfaces.trinidad.convert.DateTimeConverter.CONVERT_"+this._type; 
>>
>> > -  if(this._detail == undefined)
>> > +  if(this._messages && this._messages["detail"])
>> >    {
>> > -    facesMessage = _createFacesMessage( key,
>> > +    facesMessage = 
>> _createCustomFacesMessage(TrMessageFactory.getSummaryString(key),
>> > +                                          this._messages["detail"],
>> >                                            label,
>> >                                            parseString,
>> >                                            this._exampleString);
>> >    }
>> >    else
>> >    {
>> > -    facesMessage = 
>> _createCustomFacesMessage(TrMessageFactory.getSummaryString(key),
>> > -                                          this._detail,
>> > +    facesMessage = _createFacesMessage( key,
>> >                                            label,
>> >                                            parseString,
>> >                                            this._exampleString);
>> >
>> >
>> >
>>
>
>


Re: svn commit: r494818 - in /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main: java/org/apache/myfaces/trinidadinternal/convert/ javascript/META-INF/adf/jsLibs/

Posted by Matthias Wessendorf <ma...@apache.org>.
usually I do, not here.however no bug involved.
clean up and enhancements:

I changed some code on sending down the customized messageDetailXxxx.
I also provided a hook for a possible hint framework to customize the hint.
all messages are now send down in a map.

(same for the "some vali work" commit)

-M

On 1/10/07, Adam Winer <aw...@gmail.com> wrote:
> Matthias,
>
> Could you provide more detailed logs than "some converter work"?
> It'd help for knowing what's up with the project - and, if a bug
> gets in, very helpful for looking through the log and figuring out what
> might have triggered the problem.
>
> -- Adam
>
>
> On 1/10/07, matzew@apache.org <ma...@apache.org> wrote:
> > Author: matzew
> > Date: Wed Jan 10 06:06:22 2007
> > New Revision: 494818
> >
> > URL: http://svn.apache.org/viewvc?view=rev&rev=494818
> > Log:
> > some converter works
> >
> > Modified:
> >     incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java
> >     incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java
> >     incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
> >     incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
> >
> > Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java
> > URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java?view=diff&rev=494818&r1=494817&r2=494818
> > ==============================================================================
> > --- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java (original)
> > +++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/ColorConverter.java Wed Jan 10 06:06:22 2007
> > @@ -15,20 +15,21 @@
> >   */
> >  package org.apache.myfaces.trinidadinternal.convert;
> >
> > +import java.io.IOException;
> >  import java.util.Collection;
> >  import java.util.Collections;
> > +import java.util.HashMap;
> >  import java.util.Map;
> >
> > -import javax.faces.application.FacesMessage;
> >  import javax.faces.component.UIComponent;
> >  import javax.faces.context.FacesContext;
> >
> >  import org.apache.myfaces.trinidad.convert.ClientConverter;
> >  import org.apache.myfaces.trinidad.logging.TrinidadLogger;
> > -import org.apache.myfaces.trinidad.util.MessageFactory;
> >  import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlUtils;
> >  import org.apache.myfaces.trinidadinternal.share.text.RGBColorFormat;
> >  import org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.XhtmlLafUtils;
> > +import org.apache.myfaces.trinidadinternal.util.JsonUtils;
> >
> >  /**
> >   * @author The Oracle ADF Faces Team
> > @@ -139,10 +140,7 @@
> >     */
> >    public String getClientConversion(FacesContext context, UIComponent component)
> >    {
> > -    int patternsArgSize = _getPatternsArgSize();
> > -
> > -    int size = 19 + patternsArgSize + 19;
> > -    StringBuilder sb = new StringBuilder(size);
> > +    StringBuilder sb = new StringBuilder();
> >
> >      StringBuilder patterns = new StringBuilder();
> >      String[] setPatterns = getPatterns();
> > @@ -168,25 +166,35 @@
> >
> >      sb.append(XhtmlLafUtils.escapeJS(patternsString));
> >
> > +    Map<String, String> messages = new HashMap<String, String>();
> >
> >      String convMsgDet = getMessageDetailConvert();
> >      if(convMsgDet != null)
> >      {
> > -      Object[] params = new Object[] {"{0}", "{1}", "{2}"};
> > -
> > -      FacesMessage msg = MessageFactory.getMessage(context, CONVERT_MESSAGE_ID,
> > -                                             convMsgDet, params);
> > -
> > -      sb.append("','");
> > -      sb.append(XhtmlLafUtils.escapeJS(msg.getDetail()));
> > +      messages.put("detail", convMsgDet);
> >      }
> > +
> > +    String hint = getHintFormat();
> >
> > -    sb.append("')");
> > +    if(hint != null)
> > +    {
> > +      messages.put("hint", hint);
> > +    }
> > +
> > +    sb.append("',");
> > +    try
> > +    {
> > +      JsonUtils.writeMap(sb, messages, false);
> > +    }
> > +    catch (IOException e)
> > +    {
> > +      sb.append("null");
> > +    }
> > +    sb.append(')');
> >
> >      return sb.toString();
> >    }
> >
> > -
> >    public int getColumns(
> >      FacesContext context)
> >    {
> > @@ -200,26 +208,6 @@
> >        columns = Math.max(columns, new RGBColorFormat(patterns[i]).length());
> >
> >      return columns;
> > -  }
> > -
> > -  // Returns the length of the patterns argument
> > -  private int _getPatternsArgSize()
> > -  {
> > -    String[] patterns = this.getPatterns();
> > -    int count = patterns.length;
> > -
> > -    if (count == 1)
> > -      return patterns[0].length();
> > -
> > -    int size = 11; // Leave room for "new Array()"
> > -
> > -    for (int i = 0; i < count; i++)
> > -    {
> > -      // Include room for the pattern, comma, and quotes
> > -      size += (patterns[i].length() + 3);
> > -    }
> > -
> > -    return size;
> >    }
> >
> >    // Appends the patterns argument to the StringBuilder
> >
> > Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java
> > URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java?view=diff&rev=494818&r1=494817&r2=494818
> > ==============================================================================
> > --- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java (original)
> > +++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java Wed Jan 10 06:06:22 2007
> > @@ -15,11 +15,13 @@
> >   */
> >  package org.apache.myfaces.trinidadinternal.convert;
> >
> > +import java.io.IOException;
> >  import java.text.DateFormat;
> >  import java.text.SimpleDateFormat;
> >  import java.util.Collection;
> >  import java.util.Collections;
> >  import java.util.Date;
> > +import java.util.HashMap;
> >  import java.util.Locale;
> >  import java.util.Map;
> >  import java.util.TimeZone;
> > @@ -38,6 +40,7 @@
> >  import org.apache.myfaces.trinidad.util.MessageFactory;
> >  import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlUtils;
> >  import org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.XhtmlLafUtils;
> > +import org.apache.myfaces.trinidadinternal.util.JsonUtils;
> >
> >  /**
> >   * <p>
> > @@ -206,7 +209,7 @@
> >      }
> >
> >      String jsPattern = getJSPattern(context);
> > -
> > +    Map<String, String> messages = new HashMap<String, String>();
> >      if (jsPattern != null)
> >      {
> >        String pattern = getPattern();
> > @@ -221,37 +224,47 @@
> >            "{0}", "{1}", "{2}"
> >        };
> >        Object msgPattern = getMessagePattern(context, key, params, component);
> > +      String hintFormat = getHintFormat();
> >
> >        FacesMessage msg = null;
> >        String detailMessage = null;
> > -      int customMessages = 0;
> > +
> >        if (msgPattern != null)
> >        {
> >          msg = MessageFactory.getMessage(context, key, msgPattern, params,
> >              component);
> >          detailMessage = XhtmlLafUtils.escapeJS(msg.getDetail());
> > -        customMessages = 6 + detailMessage.length();
> > -
> >        }
> > +
> >        String exampleString = XhtmlLafUtils.escapeJS(getExample(context));
> >        String escapedType = XhtmlLafUtils.escapeJS(getType().toUpperCase());
> >
> > -      StringBuilder outBuffer = new StringBuilder(33 + jsPattern.length()
> > -          + exampleString.length() + escapedType.length() + customMessages);
> > -      outBuffer.append("new TrDateTimeConverter("); // 21
> > -      outBuffer.append(jsPattern); // jsPattern.length
> > -      outBuffer.append(",null,'"); // 7
> > -      outBuffer.append(exampleString); // exampleString.length
> > -      outBuffer.append("','"); // 3
> > -      outBuffer.append(escapedType); // escapedKey.length
> > +      StringBuilder outBuffer = new StringBuilder();
> > +      outBuffer.append("new TrDateTimeConverter(");
> > +      outBuffer.append(jsPattern);
> > +      outBuffer.append(",null,'");
> > +      outBuffer.append(exampleString);
> > +      outBuffer.append("','");
> > +      outBuffer.append(escapedType);
> > +      outBuffer.append("'");
> >
> > -      if (msgPattern != null)
> > +      if (msgPattern != null || hintFormat != null)
> >        {
> > -        outBuffer.append("','"); // 3
> > -        outBuffer.append(detailMessage); // detail message.length/
> > +        messages.put("detail", detailMessage);
> > +        messages.put("hint", hintFormat);
> > +        outBuffer.append(',');
> > +
> > +        try
> > +        {
> > +          JsonUtils.writeMap(outBuffer, messages, false);
> > +        }
> > +        catch (IOException e)
> > +        {
> > +          outBuffer.append("null");
> > +        }
> >        }
> >
> > -      outBuffer.append("')"); // 2
> > +      outBuffer.append(')'); // 2
> >
> >        return outBuffer.toString();
> >      } else
> >
> > Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js
> > URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js?view=diff&rev=494818&r1=494817&r2=494818
> > ==============================================================================
> > --- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js (original)
> > +++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/ColorFormat.js Wed Jan 10 06:06:22 2007
> > @@ -21,13 +21,13 @@
> >    pattern,
> >    allowsTransparent,
> >    patternsString,
> > -  detail)
> > +  messages)
> >  {
> >    // for debugging
> >    this._class = "TrColorConverter";
> >    this._allowsTransparent = allowsTransparent;
> >    this._patternsString = patternsString;
> > -  this._detail = detail;
> > +  this._messages = messages;
> >
> >    if (pattern != null)
> >    {
> > @@ -42,9 +42,18 @@
> >
> >  TrColorConverter.prototype.getFormatHint = function()
> >  {
> > -       return TrMessageFactory.createMessage(
> > -    "org.apache.myfaces.trinidad.convert.ColorConverter.FORMAT_HINT",
> > -         this._pattern);
> > +       if(this._messages && this._messages["hint"])
> > +       {
> > +    return TrMessageFactory.createCustomMessage(
> > +      this._messages["hint"],
> > +      this._pattern);
> > +       }
> > +       else
> > +       {
> > +    return TrMessageFactory.createMessage(
> > +      "org.apache.myfaces.trinidad.convert.ColorConverter.FORMAT_HINT",
> > +      this._pattern);
> > +       }
> >  }
> >  TrColorConverter.prototype.getAsString = function(
> >    formatColor)
> > @@ -96,18 +105,18 @@
> >
> >    var facesMessage;
> >    var key = "org.apache.myfaces.trinidad.convert.ColorConverter.CONVERT";
> > -  if(this._detail == undefined)
> > +  if(this._messages && this._messages["detail"])
> >    {
> > -    facesMessage = _createFacesMessage(key,
> > +    facesMessage = _createCustomFacesMessage(
> > +                                       TrMessageFactory.getSummaryString(key),
> > +                                       this._messages["detail"],
> >                                         label,
> >                                         parseString,
> >                                         this._patternsString);
> >    }
> >    else
> >    {
> > -    facesMessage = _createCustomFacesMessage(
> > -                                       TrMessageFactory.getSummaryString(key),
> > -                                       this._detail,
> > +    facesMessage = _createFacesMessage(key,
> >                                         label,
> >                                         parseString,
> >                                         this._patternsString);
> >
> > Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
> > URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js?view=diff&rev=494818&r1=494817&r2=494818
> > ==============================================================================
> > --- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js (original)
> > +++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js Wed Jan 10 06:06:22 2007
> > @@ -1021,7 +1021,7 @@
> >    locale,
> >    exampleString,
> >    type,
> > -  detail
> > +  messages
> >    )
> >  {
> >
> > @@ -1029,7 +1029,7 @@
> >    this._class = "TrDateTimeConverter";
> >    this._exampleString = exampleString;
> >    this._type = type;
> > -  this._detail = detail;
> > +  this._messages = messages;
> >    this._offset = null;
> >
> >    // save the Locale elements for the specified locale, or client locale
> > @@ -1050,9 +1050,19 @@
> >
> >  TrDateTimeConverter.prototype.getFormatHint = function()
> >  {
> > -       return TrMessageFactory.createMessage(
> > -    "org.apache.myfaces.trinidad.convert.DateTimeConverter.FORMAT_HINT",
> > -    this._pattern);
> > +       if(this._messages && this._messages["hint"])
> > +       {
> > +    return TrMessageFactory.createCustomMessage(
> > +      this._messages["hint"],
> > +      this._pattern);
> > +
> > +       }
> > +       else
> > +       {
> > +    return TrMessageFactory.createMessage(
> > +      "org.apache.myfaces.trinidad.convert.DateTimeConverter.FORMAT_HINT",
> > +      this._pattern);
> > +       }
> >  }
> >
> >  TrDateTimeConverter.prototype.getAsString = function(
> > @@ -1112,7 +1122,6 @@
> >    label
> >    )
> >  {
> > -
> >    // The following are from the javadoc for DateTimeConverter
> >    // If the specified String is null, return a null. Otherwise, trim leading and trailing whitespace before proceeding.
> >    // If the specified String - after trimming - has a zero length, return null.
> > @@ -1127,17 +1136,17 @@
> >
> >    var facesMessage;
> >    var key = "org.apache.myfaces.trinidad.convert.DateTimeConverter.CONVERT_"+this._type;
> > -  if(this._detail == undefined)
> > +  if(this._messages && this._messages["detail"])
> >    {
> > -    facesMessage = _createFacesMessage( key,
> > +    facesMessage = _createCustomFacesMessage(TrMessageFactory.getSummaryString(key),
> > +                                          this._messages["detail"],
> >                                            label,
> >                                            parseString,
> >                                            this._exampleString);
> >    }
> >    else
> >    {
> > -    facesMessage = _createCustomFacesMessage(TrMessageFactory.getSummaryString(key),
> > -                                          this._detail,
> > +    facesMessage = _createFacesMessage( key,
> >                                            label,
> >                                            parseString,
> >                                            this._exampleString);
> >
> >
> >
>


-- 
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com