Kishan,
  I was able to work around the bug by extending LongParser and LongRenderer
with the following:

@Override
public Long parse(CharSequence object) throws ParseException {
    if ("".equals(object.toString())) {
      return null;
    }

    try
    {
        return Long.parseLong(object.toString());
    }
    catch (NumberFormatException e)
    {
        throw new ParseException(e.getMessage(), 0);
    }
}



@Override
public String render(Long object) {
    if (object == null) {
      return "";
    }
    return String.valueOf(object);
  }


And then updating my widgets to use the new renderer/parser instead of the
default one.
---------------------------------------------------
Eric Andresen


On Wed, Jun 22, 2011 at 1:35 PM, Kishan <[email protected]> wrote:

> I am also facing the same problem. If you got any solution, please
> share.
>
> Thanks in Advance
>
> On Feb 17, 12:24 pm, Eric Andresen <[email protected]> wrote:
> > Here is the simplest code to reproduce the problem:
> >
> >         Long number = 6920835985627925859L ;
> >         logger.severe("Original " + number);
> >         logger.severe("From renderer: " +
> > LongRenderer.instance().render(number));
> >         logger.severe("From parser: " +
> > LongParser.instance().parse(LongRenderer.instance().render(number)));
> >
> > Output:
> > Thu Feb 17 10:20:45 CST 2011
> > SEVERE: Original 6920835985627925859
> > Thu Feb 17 10:20:45 CST 2011
> > SEVERE: From renderer: 6,920,835,985,627,925,859
> > Thu Feb 17 10:20:45 CST 2011
> > SEVERE: From parser: 6920835985627925504
> >
> > ---------------------------------------------------
> > Eric Andresen
> >
> >
> >
> >
> >
> >
> >
> > On Wed, Feb 16, 2011 at 4:11 PM, Eric Andresen <[email protected]>
> wrote:
> >
> > > I have an editor that uses a ValueBoxBase<Long> to store a very large
> number.  The box is read-only, but it my number gets changed between
> setValue() and getValue().
> > > Basically, when I set value  6920835985627925836 and then immediately
> get the value, it returns 6920835985627925504 .
> > > The value shows up properly in the editor itself, but when getValue is
> called, the wrong value comes back.
> > > I think the problem is in LongParser (
> http://google-web-toolkit.googlecode.com/svn/trunk/user/src/com/googl...
> >
> > >   public Long parse(CharSequence object) throws ParseException {
> > >     if ("".equals(object.toString())) {
> > >       return null;
> > >     }
> > >     try {
> > >       return (long)
> NumberFormat.getDecimalFormat().parse(object.toString());
> > >     } catch (NumberFormatException e) {
> > >       throw new ParseException(e.getMessage(), 0);
> > >     }
> > >   }
> >
> > > In this case, parse returns a double, which is then cast to a long.  I
> think this is chopping a couple bits of precision off of my Long, causing
> the mutation.
> > > Can anyone verify if this is correct or not, and if there is an Editor
> widget that can support the full range on a Long ?  (This is in GWT 2.2)
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups "Google Web Toolkit" group.
> > > To post to this group, send email to
> [email protected].
> > > To unsubscribe from this group, send email to
> [email protected].
> > > For more options, visit this group athttp://
> groups.google.com/group/google-web-toolkit?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to