Wednesday, December 29, 2010

Re: Large object graph / Serialization Concerns

Suggestion#1

if the file is that large (500k),
its structure might include a list of elements.

for example:

<orders>
<order id=""> </order>
<orderid=""> </order>
...
<orderid=""><order>
<orders>

in that case, send only a partial list to the client, for example the
first 20 or 50 items.
and when the client needs more, fetch the next 50.
do you think the client will view/edit all of the information at
once ?

Suggestion#2

client doesnt have to care about the storage format of data on the
server (xml)

in GWT (Javascript environment), you have only Strings, everything is
a String,
you might use GWT's EntityProxy's, which make it easier to deal with
client/server
marshalling/unmarshalling of data.

and use GWT EntityProxy to define Proxies that client can use.
the idea behind proxy is , since GWT is JavaScript environment,
Java Reflection doesnt work, therefore you cant use the same Entity on
client and server,
you have to use DataTransferObjects, but it might require a lot of
boiler plate, that EntityProxy alleviate that.


therefore,what I suggest is this:

Define an Object Structure for your XML file.

<order id="xx" date="xxx" total="xxx"/>
class Order {
Long id;
Date date;
}

an XML file will result in

Entity Hierarchy on the server

EntityProxy on the client

your client and server communicate using GWT communication and data
manipulation mechanisms,

therefore your client/server interaction is independent of XML.
its all String that are being exchanged.

once the client decides to save the changes,
sends an Asynchronous request,
and you can Asynchronously convert the object structure into XML, and
save.

The Steps are like follows:

1- get the XML from DB
2- load XML elements into corresponding Object Hierarchy (Entities)
(preferably only the first 50, put them in an Array/List)
3- transfer these to the client using GWT RequestFactory mechanism.

4- let the client edit all the data manipulation locally, communicate
with server only when client requires more data,
or wants to persist its actions. [ use GWT RequestFactory/
RequestContext/ValueProxy/EntityProxy ]


5- when the client decides to finally save, send an "Asynchronous"
request to the server,
to finalize the update, in this last step you turn your Java Objects
into XML and save !

client doesnt have to know whether its XML or whatever,
leverage the power of client-side processing with GWT,
dont frustrate user with unnecessary server calls.

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

No comments:

Post a Comment