View Full Version : displaying static content using GXT

21 Oct 2009, 1:31 AM
I am designing a home page for my website using GWT ext (GXT). It contains a lot of static contents like news etc that usually goes on the home page.
Firstly I tried separating the static content into html files and reading them using java.io.FileReader to set them on the Panel's setHtml(). I realized that GWT SDK does not allow to use java.io.* on the client side. The only way I have now is to place the static content into hard-coded string values like

Panel panel = new Panel();
panel.setHtml("<p>News</p><p> news news nes newsnsnwensd nsdnewes</p>");

I have got a lot of static content to display on the home page which is quite annoying to place in the String. Is there any other way/solution around.


21 Oct 2009, 9:12 PM
You could put your content in am xml file on the server and process this on the client.

22 Oct 2009, 12:42 AM
Thanks francescoNemesi for the reply.
But this will require the client to communicate with the server for the data (xml) .
I don't want any communication for the static contents. Is there any other way around it that can possibly allow me to add the contents into the client code directly by using GXT.

22 Oct 2009, 12:51 AM
I see... stange... You could use the setUrl method of the ContentPanel or add an HtmlContainer to another LayoutContainer, HtmlContainer has a setHtml method where you can "plug" your own html snippets.

22 Oct 2009, 1:11 AM
I am already passing static data to setHtml() method. But there is a lot of html contents...
for example like the help pages, blogs or articles, I dont want them to retreive using a server call.

22 Oct 2009, 1:13 AM
You can write an own GWT generator that fetches the content of the files and inlnie them to your generated javascript.

22 Oct 2009, 1:15 AM
sorry sven, Could you plz elaborate the term "GWT generator".

22 Oct 2009, 1:17 AM
Its the holy thing in GWT everything is based on. I cannot explain it here in detail, just usegoogle and you will find hundreds of details.

22 Oct 2009, 1:25 AM
Sorry, I am quite new to this GWT. Anyways I have googled it and reading through it.. seems interesting ... Thx for the reply

22 Oct 2009, 1:27 AM
You can also use GWT2 (from SVN or MS1) and use clientbundle.

23 Oct 2009, 6:51 AM
I find out and tested an easy solution. Frame
(http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/ui/Frame.html) (http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/ui/Frame.html)
can be used. It takes a url [ which can refer to a resource ] and display the contents.