Using custom XML loader in GWT/ GWT-Ext

1 view
Skip to first unread message

aviral

unread,
Aug 29, 2008, 11:04:28 AM8/29/08
to GWT-Ext Developer Forum
All,

I am comparatively new to the technology and quite impressed with what
I've seen so far. I'm facing some issues though with the first thing
that I'm trying to do with it.

I have my data stored in the XML format on the disk. The task it to
read it and message and group the data in a nice row-column format
before presenting. I have copied the XML to public directory and can
read it with the help of HttpProxy/ XmlReader classes. The issue is I
don't get a handle on the data, so not able to organize the way I need
to present it. I have read the samples but they all seem to be
presenting XMLs which are written in a ready-to-present fashion.

Can someone suggest if there is a way I can use a custom XML loader or
if there is a way I can extract the data out of the Store object?

Pl help!!!

Sanjiv Jivan

unread,
Aug 29, 2008, 11:30:18 AM8/29/08
to gwt...@googlegroups.com
Hi Aviral,
Do you need the xml data to be presented in a grid? I take it you need to add some extra stuff when you massage the original xml file before its consumed by HttpProxy and loaded into a Store. I'd suggest that you do all the XML data massaging on the server side and not the client side.

You can do this by

1) creating a servlet that reads the original XML on the sever and massages it and makes it available to the client when they hit a certain URL like users.dxml. Here users.dxml maps to your servlet that manipulates the original xml and returns it to the client. Make sure you specify a mime type of text/xml.

2) Create a GWT-RPC call massages the original xml on the server and returns the massaged xml as a String. You can then load this data into a store by calling store.loadXmlData(..). See http://gwt-ext.com/demo/#localXmlGrid

Sanjiv

aviral

unread,
Aug 29, 2008, 12:23:15 PM8/29/08
to GWT-Ext Developer Forum
Sanjiv,

Thanks so much for the tips. A little more clarification would help a
lot.

1. Yes, I do need to present the data in a grid after combining data
from 2-3 XMLs and grouping them in a particular structure. Here's a
simple version of what this looks like:

1st XML: (sectors.xml)
---------------------------------
<Sectors>
<Sector id="10">Consumer Discretionary</Sector>
<Sector id="20">Consumer Staples</Sector>
<Sector id="30">Energy</Sector>
</Sectors>

2nd XML: (stocks.xml)
---------------------------------
<Stocks>
<Stock id="APEI" sectorId="10">APEI</Stock>
<Stock id="EL" sectorId="20">EL</Stock>
<Stock id="EVEP" sectorId="20">EVEP</Stock>
</Stocks>

I need to read both and present them in a grid like:

Consumer Discretionary Consumer Staples
------------------------------------ --------------------------
APEI EL
EVEP

I want to read the XMLs and organize the data in a value object. Then
I can use this to create the Store and pass to something like
GridPanel. Pl suggest if my approach is correct.

2. Also, these XMLs may get updated every few minutes. I have to keep
reading these and flowing back to client. Does the servlet idea work
for this where server should be pushing data to client?

And a general request: the demo URL doesn't work for me. It fails with
a java script error (on line 299) which looks like: function ucc(a)
{if(a<=30){return 1&lt;<a}else{return ucc(30)*ucc(a-30)}}.

Thank you so much for all help.

Aviral


On Aug 29, 11:30 am, "Sanjiv Jivan" <sanjiv.ji...@gmail.com> wrote:
> Hi Aviral,
> Do you need the xml data to be presented in a grid? I take it you need to
> add some extra stuff when you massage the original xml file before its
> consumed by HttpProxy and loaded into a Store. I'd suggest that you do all
> the XML data massaging on the server side and not the client side.
>
> You can do this by
>
> 1) creating a servlet that reads the original XML on the sever and massages
> it and makes it available to the client when they hit a certain URL like
> users.dxml. Here users.dxml maps to your servlet that manipulates the
> original xml and returns it to the client. Make sure you specify a mime type
> of text/xml.
>
> 2) Create a GWT-RPC call massages the original xml on the server and returns
> the massaged xml as a String. You can then load this data into a store by
> calling store.loadXmlData(..). Seehttp://gwt-ext.com/demo/#localXmlGrid
>
> Sanjiv
>
>
>
> On Fri, Aug 29, 2008 at 11:04 AM, aviral <aviralmis...@gmail.com> wrote:
>
> > All,
>
> > I am comparatively new to the technology and quite impressed with what
> > I've seen so far. I'm facing some issues though with the first thing
> > that I'm trying to do with it.
>
> > I have my data stored in the XML format on the disk. The task it to
> > read it and message and group the data in a nice row-column format
> > before presenting. I have copied the XML to public directory and can
> > read it with the help of HttpProxy/ XmlReader classes. The issue is I
> > don't get a handle on the data, so not able to organize the way I need
> > to present it. I have read the samples but they all seem to be
> > presenting XMLs which are written in a ready-to-present fashion.
>
> > Can someone suggest if there is a way I can use a custom XML loader or
> > if there is a way I can extract the data out of the Store object?
>
> > Pl help!!!- Hide quoted text -
>
> - Show quoted text -

Sanjiv Jivan

unread,
Sep 3, 2008, 10:05:29 AM9/3/08
to gwt...@googlegroups.com
1. Okay, so have your servlet combine and process the XML appropriately. There are several Java libraries for manipulating XML. I like JDOM.

2. You'll need to have the client call store.reload() which when configured with HttpProxy will issue a request to a URL that hits your servlet and returns the new data.

Regarding the JS error on the demo, it is probably some Firewall  software you are running that is interfering.

See

http://gwt-ext.com/forum/viewtopic.php?f=8&t=2184&p=7190#p7190

http://gwt-ext.com/forum/viewtopic.php?f=8&t=1709

Sanjiv
Reply all
Reply to author
Forward
0 new messages