using GWT to simplify a big stack of data transformation

58 views
Skip to first unread message

Domenico

unread,
Feb 28, 2012, 3:49:39 AM2/28/12
to Google Web Toolkit
Hi,
I'm trying to simplify the stack of a web application (based on J2EE)
that takes an XML profile from backend convert it in a POJO (with some
XML data binding tool) and then throughout several data
transformations it becomes a view bean and then presented in
JavaScript. The idea is to simplify this stack using XMLBeans to
generate automatically the POJO and using directly this POJO in the
GWT application (without any intermediate transformation). Do you
think is it possible to use this strategy, in particular using a
normal POJO in the GWT application?

Thanks a lot for your help

saida dhanavath

unread,
Feb 29, 2012, 3:42:55 AM2/29/12
to google-we...@googlegroups.com
Hi,

As long as you provide the required source code for the generated POJO's to GWT compiler for generating the JavaScript it will work. 

But, I think when you generate POJO's using XMLBeans, your POJO's will have some dependency on XMLBeans (Data Binding) annotations and GWT compiler forces you to provide the source code of XMLBeans, I don't think it's a good idea use generated POJO's in GWT client code.

we also had very similar requirement, and we went on having separate view beans for GWT client.

I hope this helps you!

Regards,
Saida.


--
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-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.




--
Regards,
Saida Dhanavath

JoseM

unread,
Feb 29, 2012, 3:02:29 PM2/29/12
to google-we...@googlegroups.com
You can also use RequestFactory ValueProxy


On Wednesday, February 29, 2012 3:42:55 AM UTC-5, Sai wrote:
Hi,

As long as you provide the required source code for the generated POJO's to GWT compiler for generating the JavaScript it will work. 

But, I think when you generate POJO's using XMLBeans, your POJO's will have some dependency on XMLBeans (Data Binding) annotations and GWT compiler forces you to provide the source code of XMLBeans, I don't think it's a good idea use generated POJO's in GWT client code.

we also had very similar requirement, and we went on having separate view beans for GWT client.

I hope this helps you!

Regards,
Saida.


On Tue, Feb 28, 2012 at 2:19 PM, Domenico wrote:
Hi,
I'm trying to simplify the stack of a web application (based on J2EE)
that takes an XML profile from backend convert it in a POJO (with some
XML data binding tool) and then throughout several data
transformations it becomes a view bean and then presented in
JavaScript. The idea is to simplify this stack using XMLBeans to
generate automatically the POJO and using directly this POJO in the
GWT application (without any intermediate transformation). Do you
think is it possible to use this strategy, in particular using a
normal POJO in the GWT application?

Thanks a lot for your help



--
Regards,
Saida Dhanavath

Domenico

unread,
Mar 1, 2012, 3:39:46 AM3/1/12
to Google Web Toolkit
Hi, thanks both for the answers. OK maybe use the POJOs in client code
will not be a good idea, but my idea was to generate POJOs on the
server side and passing to the GWT client through RPC. Do you think it
is feasible ?

On Feb 29, 9:42 am, saida dhanavath <dhana....@gmail.com> wrote:
> Hi,
>
> As long as you provide the required source code for the generated POJO's to
> GWT compiler for generating the JavaScript it will work.
>
> But, I think when you generate POJO's using XMLBeans, your POJO's will have
> some dependency on XMLBeans (Data Binding) annotations and GWT compiler
> forces you to provide the source code of XMLBeans, I don't think it's a
> good idea use generated POJO's in GWT client code.
>
> we also had very similar requirement, and we went on having separate view
> beans for GWT client.
>
> I hope this helps you!
>
> Regards,
> Saida.
>

saida dhanavath

unread,
Mar 1, 2012, 9:31:31 AM3/1/12
to google-we...@googlegroups.com
Hello,

I'm asking you " What do mean by generating POJO at server?"
 
what I am assuming is it's not a dynamic POJO generation I mean at runtime, If this is the your answer, Yes it is not possible to pass POJO objects through GWT RPC mechanism, because you know, GWT RPC generates some serialization policies based on the POJO types.

If your POJO generation is static, Yes you can pass them through GWT RPC as shown in the below examples.

Example-1: Say you have generated "ViewModelPOJO" and put under a shared package, which means that both client and server code can use the POJO. 

the basic idea here is you should share the source code of your POJO's with the GWT client code for GWT compiler to generate the equivalent Java Script code.

Inline image 1   

Client ------------ .JS
Server-----------.CLASS
Shared---------.CLASS + .JS

Example-2: say you have generated the View POJO in a separate project. what you should do is add .gwt.xml file in your project as shown below.
Inline image 2

generate a source jar for the above project and put it in classpath of your GWT project  and inherit the samplePOJO gwt module in Sample.gwt.xml GWT module (as shown in example1)  and you can use them both in the client and server, I mean you can pass them back and forth (client-server).

I think this clarifies your question.

Regards,
Saida.
image.png
image.png

JoseM

unread,
Mar 1, 2012, 10:57:53 AM3/1/12
to google-we...@googlegroups.com
What you are asking for is feasible doing what Sai described but I think it would be better for you to use ValueProxy with the @ProxyFor annotation, that is easier than creating a POJO just for the client side and then writing code to convert your server POJO to another client specific POJO.  Using RequestFactory and a ValueProxy ,GWT will automatically copy over the fields neccessary and provide other benefits that come with RequestFactory.

Reply all
Reply to author
Forward
0 new messages