Hey people, I know I have pasted the link to this my blog post as
answer to quite a few questions but somehow this post seems to be to
answer to quite a few questions here. So here it goes again ...

http://h2g2java.blessedgeek.com/2010/02/tutorial-gwt-rpc-stub-modified-with.html.

The trick is not to pass String but HashMap (or your own serializable
type).

I know, the recommended way is to pass json but I really didn't want
to deal with constructing and deconstructing the json myself because I
am addicted to the cleanliness of coding in Java. I let GWT handle the
dirt of javascript and json, where GWT translates/marshalls and then
detranslate/demarshalls my serializables into/from json(I believe) for
me.

In the HashMap<String, String>, I set the key as param name and hash
value as param value.

I think for most needs, either HashMap<String, String> or
HashMap<String, String[]> would really satisfy most applcations.

.....
For more complex apps that require passing hierachical information, I
also have an xpath enabled Hashtree which I think could be used, which
you could find in my google code project.

However, it has not been tested out with GWT yet because GWT required
@typeargs annotation, which is impossible for a hash tree.  However, I
get the impression that GWT 2.0 no longer requires typeargs annotation
as long as the parameter passed is gwt-white-listed-serializable. Is
it true? - I need to test it out.

The way it works is you just instantiate on single object and use
xpath-like keys:

HashTreeNode paramtree = new HashTreeNode();
paramtree.setKeyDelimiter('/'); // default delimiter is / anyway

The following would create a cascade of three hashnodes
paramtree.put("/projects/zanzibar/manager", "San Fran Man");

The following would create only one additional 3rd level node since
the node "/projects/zanzibar" has already been previously created.
paramtree.put("/projects/zanzibar/description", "San Fran Man");

Most (if not all) people would use the whole string "/projects/
zanzibar/manager" as the key to "San Fran Man". However my hashtree
would separate them into nodes
"projects" -> "zanzibar" -> "manager" -> "San Fran Man".

In this way, for a deep/tall xpath,
"/departments/engineering/facilities/projects/zanzibar/manager",

I could simply grab the cut-tree zanzibar,
HashTreeNode zan = paramtree.get("/departments/engineering/facilities/
projects/zanzibar");

I could then use zan to access all members of zanzibar, without
needing to repeatedly use the long parent path of the key:
zan.get("manager"); zan.get("description"); zan.get("cost code");,
etc.

Whereas, if you stored the whole strings as key, you would have a hard
time dissecting members a each level of the path.

-- 
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