Properties file with GWT

2,615 views
Skip to first unread message

Deepak Singh

unread,
Sep 14, 2012, 3:36:06 PM9/14/12
to google-we...@googlegroups.com
Hi,

I have some div id's in my host html page. Which might change regularly, based on that we will show / hide some content.
I need to manage this requirement.

I thought to update the id's in a properties file on client side and the file will be read on client side and shows / hides the content based on id's found in properties file.

Is it a good approach ?

If yes, how to use properties file ?

Regards
Deepak Singh

Chris Lercher

unread,
Sep 15, 2012, 5:20:01 AM9/15/12
to google-we...@googlegroups.com
1. The java.util.Properties class isn't available on the client side. It's possible to get a properties file to the client side (e.g. using com.google.gwt.http.client.RequestBuilder), but you'd have to find a way to parse it. So why not use JSON format instead? Or GWT-RPC (which can contain the ids as a Collection or Map, or whatever you need)?

2. It sounds as if you don't have any control over your host page, but if you do, it would be more efficient to put the data directly there, similar to the example in http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/i18n/client/Dictionary.html. This way you wouldn't need to make the extra server request.

3. Another possibility would be to have the values directly in your GWT client side source code. This would however require a re-compile of your client code, and a reload by the user. If you choose this option, and you still want a Properties file or something, you can use a TextResource to directly include it with the GWT JavaScript file (see https://developers.google.com/web-toolkit/doc/latest/DevGuideClientBundle#TextResource)
Reply all
Reply to author
Forward
0 new messages