On 09/06/2009 03:02 PM, Marcelo Sena wrote:
>
> Yes I have but I don't see how I could use it to send or receive
> portions of an object, like, now the key, now an email, now a name
> etc. I don't see how it could help when handling portions of an
> object. Is that possible?
I'm going assume you mean data structures like
{ "key": 1234} or {"email" : "[email protected]"}
You're right in the sense that JSO types seem designed for "complete"
objects, as opposed to object fragments.
AFAIK, a reference for a "complete" object that resembles
{"server":{"id":2,"name":"fred"}}
might look like:
public final native String getName() /*-{
return this.server.name;
}-*/;
For objects that are the subject of this thread, I think you get by with:
public final native String getEMail() /*-{
return this.email;
}-*/;
All of the above examples go into a JSO type class declaration
public class UserInfo extends JavaScriptObject {
protected UserInfo() {}
}
but the email example does not reference the class object like the
server name does.
I think one potential problem you'll have with this implementation is
that you might find yourself with an annoying run-time error when the
current JSO does not have a member named "key" (or "email"), yet you
execute a code sequence that assumes the current object does have a
member named "key". This error is difficult to cause when using
"complete" JS objects.
This will be a difficult error to track down, since it will be dependent
on a particular operation sequence.
>
> On Sep 6, 6:31 pm, Jeff Chimene <[email protected]> wrote:
>> On 09/06/2009 10:51 AM, Marcelo Sena wrote:
>>
>>
>>
>>> Really why not?
>>> It was my first thought. You guys(developers at GWT) have probably
>>> created some sort of HashMap to handle JSON objects received from RPC
>>> calls handling its values and strings.
>>> Anyway, I find the standard way of handling JSON values quite... ugly.
>>> Is there any reason why shouldn't I use a process like:
>>> 1- Get string form the wire.
>>> 2- Use regex to get the name and values.
>>> 3- Fill a Map with the values from step 2.
>>> 4- Get the values that I want from the Map.
>>
>>> Thanks in advance.
>>
>> Have you looked at the Javascript Overlay type? It's quite efficient.
>> I'm guessing it's more efficient than using a
>> Map.http://code.google.com/webtoolkit/doc/1.6/DevGuideCodingBasics.html#D...
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---