• Welcome to KonaKart Community Forum. Please login or sign up.
 

Integration with GWT front-end

Started by haaking, May 07, 2008, 04:17:41 pm

Previous topic - Next topic

haaking

I am trying to write a front end site with GWT and want to use the Konakart shopping cart api on the back-end as rpc calls from my web front end.  I don't see anywhere where this is specified how I need to get things setup, i.e. what jars to include. 

Basically I just want to be able to call all the api soap services through the GWT rpc asynchronous interface.  Any help would be appreciated.

Thanks.
Greg

heidi

Hi Greg,

This is a great idea - I wish you every success with this idea and will look forward to seeing the results - please let us know when you've finished.

What I would do is create a layer of your own that receives the asynchronous calls from the GWT client and calls the KonaKart APIs (using SOAP or directly in java).

Regards,
Heidi

rula

Hi KonaKarts,

I worked through the basics and more features of googles StockWatcher tutorial and now I will start to use gwt for konakart frontends. Onepagecheckout is embedded gwt in struts. Is this a good entrypoint;-) for me as gwt newbie to start with a complete frontend. How is the way from struts to gwt? How can I simple replace the struts actions by gwt procedure calls, if possible? Many newbie questions, I try to start with the ui. Help would be nice. regards, rula

ming

It rather depends what you want to achieve.  For minor additions to the jsp version you could use techniques as used in the one-page-checkout. See gwt references in:

MainLayout.jsp:         <meta name='gwt:module' content='com.konakart.Konakart'>
OnePageCheckoutBody.jsp:<script language="javascript" src="gwt.js"></script>

Also look at CheckoutDeliveryAction.java

Also, note the web.xml servlet definition for this:

<!--  Servlet for GWT code  -->
<servlet>
  <servlet-name>KonakartGWTServlet</servlet-name>
  <display-name>KonaKart GWT App</display-name>
  <description>KonaKart GWT App</description>
  <servlet-class>com.konakart.server.KKGWTServiceImpl</servlet-class>
  <load-on-startup>10</load-on-startup>
</servlet>

Also, you could use the documentation at http://www.konakart.com/javadoc/struts_doc/index.html to help you understand the Struts configuration.

A new Google Group (http://groups.google.com/group/konakart) has been created that is dedicated to creating open source store fronts using different technologies.   It may well use GWT as the client technology but this is not yet decided.

rula

Hi ming,

I want to achieve a complete but small and simple gwt frontend.
My entrypoint could be the mail sample in googles gwt 1.5 doc.

First I try to create the ui with panels, widgets and listeners and use hardcoded data like in the mail sample too. Then I try to get the data from the clientEngine over RPC (is it correct!?). It would be not so easy for me, but little by little I recognize the possibilities of gwt.

When starts your new google group probably with development of konakart frontends.
I am interessted but only a gwt newbie.

regards, rula

ming

Hi,

It sounds like you're heading in the right direction.   I would create a GWT service layer that your GWT client calls asynchronously.  The GWT service layer can instantiate the KonaKart engines to call the APIs (via web services, or direct java calls).

The Google Group has started a discussion on the technology that should be used to build the first client.  Once that's decided, work will get underway, but I don't know when exactly.

Regards - Ming

rula

Hi KonaKarts,
I think it should be possible to run your onepagecheckout kit in a gwt application without struts but I don't
no in details what I have to do, to reach this. Okay, I could remove struts specific parts and I have to add a GWT servlet and mapping like in konakart. But than I am at the end with my knowhow. Would the rpc mechanism also work ? In moduleLoad methode of the Konakart entryPointClass theres controller logic with states and actions. Is it a good way to use all these things? regards, rula

julie

The one page checkout app is a GWT application which just happens to be embedded within a Struts app and doesn't rely on struts in any way (i.e. it runs in GWT hosted mode without struts). KKGWTServiceImpl is the class that acts as an interface between GWT and KonaKart, so you may want to take a look at it.

QuoteIn moduleLoad methode of the Konakart entryPointClass theres controller logic with states and actions. Is it a good way to use all these things?


The reason for such an implementation is to keep the decisional logic all in one place (similar to struts) but without having the luxury of a struts like framework for GWT.


rula

Hi julie,
when I run my konakart gwt app in hosted mode it throws the following exception.
Why org/apache/struts/action/Action?

regards rula

javax.servlet.ServletException: Servlet execution threw an exception

root cause

java.lang.NoClassDefFoundError: org/apache/struts/action/Action
   java.lang.ClassLoader.defineClass1(Native Method)
   java.lang.ClassLoader.defineClass(Unknown Source)
   java.security.SecureClassLoader.defineClass(Unknown Source)
   java.net.URLClassLoader.defineClass(Unknown Source)
   java.net.URLClassLoader.access$100(Unknown Source)
   java.net.URLClassLoader$1.run(Unknown Source)
   java.security.AccessController.doPrivileged(Native Method)
   java.net.URLClassLoader.findClass(Unknown Source)
   java.lang.ClassLoader.loadClass(Unknown Source)
   sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   java.lang.ClassLoader.loadClass(Unknown Source)
   java.lang.ClassLoader.loadClassInternal(Unknown Source)
   com.konakart.al.KKAppEng.<init>(Unknown Source)
   sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
   sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
   java.lang.reflect.Constructor.newInstance(Unknown Source)
   java.lang.Class.newInstance0(Unknown Source)
   java.lang.Class.newInstance(Unknown Source)
   com.konakart.server.KKGWTServiceImpl.<init>(KKGWTServiceImpl.java:149)
   sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
   sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
   java.lang.reflect.Constructor.newInstance(Unknown Source)
   java.lang.Class.newInstance0(Unknown Source)
   java.lang.Class.newInstance(Unknown Source)
   com.google.gwt.dev.shell.GWTShellServlet.tryGetOrLoadServlet(GWTShellServlet.java:953)
   com.google.gwt.dev.shell.GWTShellServlet.service(GWTShellServlet.java:278)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

julie

If you look at the source code you'll see that it uses a struts action at the points where the GWT application has to give control back to the stuts application. i.e. redirect("ShowCartItems.do");

rula

Hi julie,
I commented out all the struts redirects in the client sources and the exception remaitds. I searched all the gwt sources and I cannot find the cause. After all, in my desperation, I added the struts.jar and the exception disappears. Have you a idea?
Now I see LoginBody in hosted mode, thats a small progress for me.
I get lost in konakart gwt, the advantage of all these is that I have now an small overview about these things konakarts have done for the gwt frontend. I understand nothing, but I think it's really good, and I will use all your groundwork.
The communication seems to work. Now I will start with the Welcome page, so I build the page with panels and widgets in the manner of konakart, add the required rpc calls and extend the controller. Is this a good way? Have I to note something special because this app is not father embedded in struts?

julie

Having taken a closer look at your exception, it is the initialization of com.konakart.al.KKAppEng that is looking for Struts. In theory you could develop a GWT front end that connects just to the server engine KKEng (similar to the way that the Admin App works).

Since in the application we are using the GWT code just for the checkout, it made a lot more sense to use KKAppEng since this is being used by the Struts application and it contains some session state.

rula

Hi julie,
do you think that the connection to the KKEng ist clearer than to the KKAppEng? In this case, KKGWTServiceImp have to instatiate a KKEng engine. This could be configured in the properties files and have to changed in the sourcecode of KKGWTServiceImp? Too heavy stuff for me! I will stay in KKAppEng altough perhaps KKEng is clearer.

regards, rula

julie

If you want some really loose coupling, you could even use the SOAP interface  :)

rula

Hi julie,

I can't get debug logs from KKGWTServiceImpl in hosted mode to the eclipse consol.
I always get: Should only see this message in debug mode.

Settings in the property files of konakart,konakartadmin and in the classpath of the eclipse project. 
# Konakart classes
log4j.logger.com.konakart                     = DEBUG
log4j.logger.com.konakartadmin                = DEBUG

# KonaKart Client Logging
log4j.logger.com.konakart.clientlogging       = DEBUG

I need log infos from serverside too. Can you give me a tip? regards, rula