tags:

views:

57

answers:

3

Hi

I am trying to integrate, Seam and GWT. I was wondering if can specify html pages in Seam page flow. Is it possible ? If yes what will the name in the tranisition stand for ?

+1  A: 

Normally GWT is a client-side stateful application. This means that you run the entire application within one html page. Browser never reloads this page. If browser would reload this page then internal app state would be lost (variables, etc..).

Now, you can certainly create GWT application that has multiple html pages. Normally you would create different GWT modules and load them in separate html pages. Eclipse plugin creates a host page for every module.

You can create normal Seam application, just copy the necessary lines from GWT host pages to your Seam "pages".

Just keep in mind that this separate GWT modules share no state between them.

Edited:

You can map Seam page flow to GWT Buttons such that clicking the button takes you to the next page in pageflow:

  1. Create a GWT button with onClick handler that contains Window.Location.assign(URL). Clicking on this button will open given URL in current browser page.
  2. Make URLs of Seam pageflow pages human readable. I believe (not an expert on this) it's done with view-id="page_url" attribute inside <page> element.

This is a manual process (not type safe) that relies on you correctly matching view-id with URLs in Buttons. Change on one side will require you to manually correct the other side. To make life a bit easier you could make a function that adds a listener to Button (or any other Element in GWT).

Peter Knego
+1  A: 

We also use a combination of Seam page flow and GWT. Explicitly, we divide the login page from the main page to enable login via https. But, we do not use normal html pages, we still use xhtml pages. You can include a GWT html page within a Seam xhtml page by wrapping the <html></html> pair with a <f:view></f:view> pair:

<f:view
    contentType="text/html"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"&gt;
    <html>
        <!-- ... -->
    </html>
</f:view>

By using such a Seam wrapped html page, you do not have any trouble for defining the page transitions.

As Peter Knego already pointed out, it is advisable to use different GWT modules for different (x)html pages.

kraftan
@kraftan could you please help me with a simple example of you code.
Anand
@kraftan I am especially interested in how you map the transition actions on page flow to the gwt button actions
Anand
@Anand you cannot map a page flow to a GWT button. The communication between the GWT client and the Seam server goes through async GWT-RPC calls. Seam handles thosecalls with the GWTService. As @z00bs and @Peter Knego pointed out, using a GWT app, you do not switch between different pages. We use Seam page transitions to decide which part of our GWT app is supplied to the client. If the client is already logged in, we render main.xhtml otherwise home.xhtml. For more information on Seam+GWT read http://docs.jboss.org/seam/2.2.0.GA/reference/en-US/html/gwt.html
kraftan
You can manually create a GWT Button that maps to Seam page flow. See my post above (edited part).
Peter Knego
+1  A: 

It heavily depends on what you're trying to achieve. That is whether you're planing to create a desktop like, single page application where most of the state is held by the client or the main logic as well as the html pages is provided by the server.

If you go for the desktop like app you're likely to build up the client-side of your app entirely with GWT. For the initial request Seam returns a simple html page that fetches the .nocache.js which in return downloads the compiled main script .cache.html of your app. From here GWT takes over (starting at onModuleLoad() in the EntryPoint of the loaded module) and builds up the entire layout of your app by replacing the <body> tag of the returned html page. User interactions and state is synchronized via the server but rendering is done by GWT.

If you go for the combination of Seam and JSF you still can benefit from GWT. A common scenario is to selectively insert GWT widgets into specific places in a existing html page (see here for details). This way you can use Seam for rendering, page flow etc. and extend your pages with GWT widgets.

BTW, if you need SSL for the registration and/or user authentication (and automatic form completion!) I highly recommend to do it as recommended by @kraftan. Everything else is a pain.

z00bs