Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Bug in setAttribute() and getAttributeAsLong()?

$
0
0
I'm using
Isomorphic SmartClient/SmartGWT Framework (v9.0p_2013-09-17/Pro Deployment 2013-09-17)

it looks like I may have hit a bug/problem...
here is my easy sample code: (just hook this up to a button in the UI somewhere....
Code:

button.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                long testlong = 1115874469835382977L;
                StaticTextItem formitem = new StaticTextItem();
                formitem.setAttribute("testlong", testlong);
                long retrievedLong = formitem.getAttributeAsLong("testlong");
                SC.say(testlong+" : "+retrievedLong);
                if (testlong != retrievedLong) {
                    SC.warn("NOT EQUAL");
                }
}

the first SC.say will say
1115874469835382977 : 1115874469835383040
and the NOT EQUAL will be displayed

I would have thought this would work based on the APIs, but apparently it doesn't work. I didn't find any caveats about this in any of the javadocs. Is this fixed/addressed in the latest version maybe? My workaround is to just store it as a String and do the conversion to/from long myself but I just thought I'd mention it in case this was not a known bug. I only tried this in Firefox, if it matters.

Just to be complete, I tried it with Long instead of long (the primitive) and got the same results:
Code:

button.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                Long testlong = new Long(1115874469835382977L);
                StaticTextItem formitem = new StaticTextItem();
                formitem.setAttribute("testlong", testlong);
                Long retrievedLong = formitem.getAttributeAsLong("testlong");
                SC.say(testlong+" : "+retrievedLong);
                if (!testlong.equals(retrievedLong)) {
                    SC.warn("NOT EQUAL");
                }   
            }
        });

Thanks,
Brian

Viewing all articles
Browse latest Browse all 4756

Trending Articles