GWT and Magnolia Integration

I like GWT and I like Magnolia. What do you think about link them?

GWT will be responsible for dynamic pages. Such page will provide rich user interface with a lot of JavaScript and AJAX. Thus search engines will not index these pages, but it is not problem – Magnolia will be responsible for such pages. Also Magnolia provides some useful features like mail service, file uploading mechanism, etc. So let’s link them.

Create GWT application

First, we need to create GWT application. You may use any approach for it (IDE Plugin, Maven Plugin, etc.) and as result (after final compilate) you will have your_gwt_application.html and folder your_gwt_application with compiled application.

Note that it is better to realize your application without integration with Magnolia (using GWT tools). And only when application is ready than you may start integration.

Update your Magnolia Module

Magnolia is based on modules (add-ons) thus you may customize your Magnolia by creation own module. This module will contains all application’s templates, configuration, servlets, etc. So the first step of integration is adding GWT application into your module.

For adding GWT application into magnolia you need to do the following steps:

  • copy folder with compiled GWT application into /mgnl-files/docroot/{your_magnolia_module}
  • create template or paragraph, in which your application will be built in (you may find here how it works)
  • add HTML code, which calls your GWT application, into your template or paragraph. It looks like:

Here I have used JSP-base magnolia template.

After that you may see your GWT application on page, which is based on created template or use created paragraph. But this application does not support sever calls – you need to configure it.

Configure servlets for GWT services

Now we should configure GWT servlets for working with your application. First you need copy gwt-servlet.jar into magnolia’s lib folder.

Then open magnolia admin console and go into Configuration (in left menu) → server (in right tree) → filters → servlets. Here we need to create new servlets for each your GWT services with the following parameters:

  • mappings → {name_of_mapping} → /docroot/{your_magnolia_module}/{your_gwt_application}/{servlet_name}
  • class = info.magnolia.cms.filters.ServletDispatchingFilter
  • enabled = true
  • servletClass = {your_gwt_service_realization_class}
  • servletName = {your_servlet_name}

After that you may test your application – it should work!

Conclusion

In conclusion I’d say that it is cool approach and I like it! You may contact us to get working sample.