Research Log of Web Science Students

Computer Science is not simply programming

Posts Tagged ‘Spring-GWT

Forgive My Ignorance

leave a comment »

… but I just knew how to “array-ize” lists and such things.

List<List<TextBox>> descriptions = new ArrayList<List<TextBox>>();

… which is, in array form,

TextBox[][] descriptions = new TextBox[][];

Now I’m thinking if I have to initialize every widget add, or get them immediately (but I’m betting on the former).

List<VerticalPanel> vpanel = new ArrayList<VerticalPanel>();
// initialize component to add to vpanel
vpanel.add(new VerticalPanel());
// access it
vpanel.get(0);

Advertisements

Written by Paolo Sy

November 29, 2009 at 1:45 am

Posted in Hardwire

Tagged with , , ,

Everyone, the power of polymorphism.

leave a comment »

remoteServiceServlet

I was able to implement a tutorial that exposes GWT RPC as a Spring Bean! Now I can make use of Dependency Injection to give the the GWT-RPC services its dependencies such as Data Access Objects and other service classes. Don’t I just love POJO based development? Most probably I can unit test this as well. Now that makes it sweeter!

The GWT community has come up with a solution to integrate GWT RPC into a Spring container. The key here is simply to find a way for RPCs to get into the Spring container and be forwarded to the server POJO. This was done by implementing the controller interface and then making use of GWT’s RemoteServletService and what have you to process the call.

This was done by

1. implementing Spring’s controller interface
2. inheriting GWT’s RemoteServletService

I understand a bit what’s going on in there and I have to say that was a really smart thing to do!

But I do have my comment

I think it’s too “heavy” for each service to be implemented as a controller. Maybe the GWTRPC controller can have a list of services which can be wired in Spring and the GWTRPC controller can figure out from the payload which class it will use.

Something like this

@Override
public String processCall(String payload) throws SerializationException {
RPCRequest rpcRequest = RPC.decodeRequest(payload,
            this.remoteServiceClass);

// delegate work to the spring injected service
return RPC.invokeAndEncodeResponse(this.remoteService, rpcRequest
        getMethod(), rpcRequest.getParameters());
}

instead of using this.remoteService, do something like getRemoteService(String payload) which returns the appropriate
service class.

Another job for another day I guess.

Written by Jose Asuncion

November 2, 2009 at 6:12 pm

Posted in Hardwire

Tagged with , ,

Learning GWT-RPC

leave a comment »

1. Well first off, I got to a bumpy start.  I wanted to add a GWT module to my developer sandbox but at first I didn’t know how.

You need a module file to make GWT work and the html file where the javascript generated by GWT will be hosted. Those are  pretty complicated to setup–manually. The module file is an xml file that needs a namespace and the javascript is very — well I don’t how to start explaining where to get that from. GWT doesn’t show you the generated javascript script.

But as it turns out, the GWT plug-in takes care of this for you! (Why didn’t I think of that in the first place?) Simply hit ctrl+n and create a module, html file or entry point.

2. So I tried applying what I’ve learned and after hurdling a few mistakes (no I still can’t make GWT RPC work), I finally find myself needing to learn how to integrate GWT with Spring for Hardwire’s requirements (since it uses the Spring framework).

This is the culprit:

<servlet-mapping>
        <servlet-name>SandboxServlet</servlet-name>
	<url-pattern>/</url-pattern>
</servlet-mapping>	

<servlet-mapping>
	<servlet-name>lookupService</servlet-name>
	<url-pattern>/Rex/lookup</url-pattern>
</servlet-mapping>

Instead of the RPC going to the lookupService, it goes to the DispatcherServlet a.k.a Sandbox. That’s why I get this error:

11 1, 09 5:20:59 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/org.sandbox.Rex/lookup] 
in DispatcherServlet with name 'sandbox'

I could do a workaround by making all the requests to the url /app/*, meaning dynamic pages to go to the Sandbox dispatcher servlet while on the other hand all rpc calls destined for the lookupService must address to the url services/*.

But this is ugly, would you want to type in http://hard-wire.appspot.com/app/ to go to hardwire? I didn’t think so.

Besides I’ve always wanted the the RPC service to be exposed as a spring bean so that I can make use of the other POJOs I’ve made.

Ergo, I am going back tomorrow and work on doing this tutorial instead. Pretty neat stuff if you ask me.

Written by Jose Asuncion

November 1, 2009 at 6:36 pm

Posted in Hardwire

Tagged with , ,