GWTP application for different platforms

803 views
Skip to first unread message

Harald Pehl

unread,
Jul 5, 2011, 9:35:15 AM7/5/11
to gwt-pl...@googlegroups.com
Hi,

I'm currently writing an application for multiple platforms (desktop, tablet, smartphone). Therefore I have a helper module with a property provider based on the user agent. In my application module I can define replace-with rules like:

<replace-with class="com.acme.client.app.ApplicationViewTablet">
    <when-type-is class="com.acme.client.app.ApplicationView" />
    <when-property-is name="formfactor" value="tablet" />
</replace-with>

I want to reuse as much code as possible and write as little code as possible per platform. Therefore I have replace-with rules for the views. This works in simple applications - e.g. if the top level presenter has the same structure for any platform. But in my case the top level presenter for the desktop has a nested PresenterWidget for the navigation which is not true for the tablet and mobile platform. So I thought about having different Ginjectors / GIN modules. But I don't how to specify the right value for gin.ginjector in my application module:

<define-configuration-property name="gin.ginjector" is-multi-valued="false" />
<!-- Can this be defined based on some property? -->
<set-configuration-property name="gin.ginjector" value="com.acme.client.gin.PlatformDependentGinjector" />

Does anybody develop applications for multiple platform? Is this a reasonable design? Do you have any ideas how to implement this?
Any suggestions, ideas and comments are are highly appreciated. 

- Harald

Christian Goudreau

unread,
Jul 5, 2011, 9:46:06 AM7/5/11
to gwt-pl...@googlegroups.com
Oh I'm also interested in that answer ! I was going to work on something similar really soon.

Cheers,
--
Christian Goudreau

Philippe Beaudoin

unread,
Jul 5, 2011, 10:48:55 AM7/5/11
to gwt-pl...@googlegroups.com
First of all, the easiest/cleanest way to do what you want would be to have the ability, in Gin, to switch bindings based on deferred binding properties (do not confuse _configuration property_). Unfortunately, it is not yet a feature in Gin. I have proposed ideas that would make this possible, if you're interested star the following or contribute your opinion:
I'm almost sure there are conversations on that topic in the group.

Unfortunately, last time I checked there were no ways to make conditional _configuration_ properties. So right now I dont see how to achieve what you want save from manually switching a GWT configuration file prior to compilation. Here are some options we could implement on the GWTP side:
1) Finally get working on Issue 207 and use Gin extensions to get rid of the need to customize the ginjector (http://code.google.com/p/gwt-platform/issues/detail?id=207)
2) Or allow for a gin.ginjectorFactory configuration parameter instead of gin.ginjector, that could use any mechanism to determine the real ginjector (based, say, on deferred binding properties).

The best is (1), but (2) is probably easier and does not make us dependent on the HEAD of gin. Personally, I'd still go with (1).

Also note that you will have to implement something like a ginjector factory internally in your entry point so that you can GWT.create() the correct ginjector based on a deferred binding property.

Cheers,

   Philippe

Christian Goudreau

unread,
Jul 5, 2011, 10:52:49 AM7/5/11
to gwt-pl...@googlegroups.com
I'd still go with one too, Gin head is stable enough for it.
--
Christian Goudreau

Thomas Broyer

unread,
Jul 5, 2011, 10:58:46 AM7/5/11
to gwt-pl...@googlegroups.com
FYI, GWT comes with a sample "multimodal" webapp: http://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/mobilewebapp/
Should be relatively easy to adapt to GWTP.

Philippe Beaudoin

unread,
Jul 5, 2011, 11:08:49 AM7/5/11
to gwt-pl...@googlegroups.com
Thanks Thomas,

The <replace-with> strategy Harald is using seems to match that example pretty well. In my experience, the problem occurs when you try to build a gin app on that model. The reason is that the bindings themselves are different. (You may bind less presenters, or some presenters may only exist in mobile or desktop...) In that case, it complexifies the design to force yourself to find a 1-to-1 mapping from your desktop presenters to your mobile presenters. What I was proposing is some mechanism to "switch the ginjector" based on deferred binding properties.

Cheers,

   Philippe

Harald Pehl

unread,
Jul 5, 2011, 3:30:33 PM7/5/11
to gwt-pl...@googlegroups.com
That are exactly the problems I'm currently fighting with, Philippe. I do have different bindings for the different platforms. I will go ahead and try to setup some kind of ginjector factory which I will choose based on my replace-with rules.

Thank all for you ideas!

BTW: The app I'm building is part of an article which might be published in the german magazine JavaSPEKTRUM. The article will also contain a short introduction to GWTP. I hope I can make a small contribution to make this great framework even more popular. I will let you know if and when the article will be published.

- Harald

Philippe Beaudoin

unread,
Jul 5, 2011, 3:32:19 PM7/5/11
to gwt-pl...@googlegroups.com
Great! Thanks. Looking forward to it.

Daniel

unread,
Jul 30, 2011, 4:53:58 AM7/30/11
to gwt-pl...@googlegroups.com
Harald, any updates on this? Did you manage to write something to achieve the different bindings for different platforms?
Would be great if you could keep us posted and share some code examples here!

Thanks, 
Daniel

Harald Pehl

unread,
Aug 1, 2011, 10:25:11 AM8/1/11
to gwt-pl...@googlegroups.com
I'm finished my demo. It's available under http://code.google.com/p/waitara/. The accompanying article is likely to be published soon.

However, the implementation has some drawbacks: 
  1. My setup is based on <replace-with> rules for the views in the GWT module. As a result I could not used constructor injection, but had to manage the dependencies myself using a static reference to the ginjector. 
  2. Actually I would like to have different bindings for the different platforms. For instance there's one list and one detail presenter in the desktop and mobile platform. Whereas in the tablet version, the list and the details is shown on the same page. But since http://code.google.com/p/google-gin/issues/detail?id=150 and http://code.google.com/p/gwt-platform/issues/detail?id=207 are not yet available I was forced to use some ugly workarounds.
- Harald

Philippe Beaudoin

unread,
Aug 2, 2011, 12:00:39 PM8/2/11
to gwt-pl...@googlegroups.com
You're <replace-with> issue is closely related to my proposal for GIN:

Cheers,

   Philippe

Prashanth Shenoy

unread,
Aug 7, 2011, 12:31:39 AM8/7/11
to GWTP
This discussion was very helpful. I am sure a lot of users of GWTP
have a very similar requirement now to support multiple platforms. And
this discussion helps to understand where we actually stand on this as
of today!

Thanks all.


On Aug 2, 9:00 pm, Philippe Beaudoin <philippe.beaud...@gmail.com>
wrote:
> You're <replace-with> issue is closely related to my proposal for GIN:http://code.google.com/p/google-gin/issues/detail?id=150
>
> Cheers,
>
>    Philippe
>
> On Mon, Aug 1, 2011 at 10:25 AM, Harald Pehl <harald.p...@googlemail.com>wrote:
>
>
>
> > I'm finished my demo. It's available under
> >http://code.google.com/p/waitara/. The accompanying article is likely to
> > be published soon.
>
> > However, the implementation has some drawbacks:
>
> >    1. My setup is based on <replace-with> rules for the views in the GWT
> >    module. As a result I could not used constructor injection, but had to
> >    manage the dependencies myself using a static reference to the ginjector.
> >    2. Actually I would like to have different bindings for the different
> >    platforms. For instance there's one list and one detail presenter in the
> >    desktop and mobile platform. Whereas in the tablet version, the list and the
> >    details is shown on the same page. But since
> >    http://code.google.com/p/google-gin/issues/detail?id=150and
> >    http://code.google.com/p/gwt-platform/issues/detail?id=207are not yet

Christian Goudreau

unread,
Nov 6, 2011, 9:09:57 AM11/6/11
to gwt-pl...@googlegroups.com
What is the status on the article? I don't speak German, but I do want to see it :D
--
Christian Goudreau

Harald Pehl

unread,
Nov 7, 2011, 6:50:56 AM11/7/11
to gwt-pl...@googlegroups.com
The publish date of the article was finally confirmed last week: It will be released in JavaSpektrum 01/2012 (20.01.2012). Don't know if there will be an online version of the article. If so I will post the link. 

- Harald

Christian Goudreau

unread,
Nov 7, 2011, 7:01:30 AM11/7/11
to gwt-pl...@googlegroups.com
Nice! Thanks!


On Mon, Nov 7, 2011 at 6:50 AM, Harald Pehl <haral...@googlemail.com> wrote:
The publish date of the article was finally confirmed last week: It will be released in JavaSpektrum 01/2012 (20.01.2012). Don't know if there will be an online version of the article. If so I will post the link. 

- Harald



--
Christian Goudreau
Message has been deleted

Harald Pehl

unread,
Jan 20, 2012, 2:57:57 AM1/20/12
to gwt-pl...@googlegroups.com
My article about the GWTP application for different platforms was finally published today. For those of you who understand german, there's an online version available: http://www.sigs-datacom.de/fileadmin/user_upload/zeitschriften/js/2012/01/pehl_JS_01_12.pdf

- Harald

Steve Buikhuizen

unread,
Mar 5, 2012, 11:17:58 PM3/5/12
to gwt-pl...@googlegroups.com
+1 on how useful this discussion was for me, probably saved me a day of experimentation. Thanks.

Christian Goudreau

unread,
Mar 9, 2012, 7:39:08 PM3/9/12
to gwt-pl...@googlegroups.com
Harald! Could you translate that in english? :D
--
Christian Goudreau

Евгений Ивлев

unread,
Dec 26, 2012, 8:20:31 AM12/26/12
to gwt-pl...@googlegroups.com
Hello, guys!

Been a long time... Does it exist now a way for conditional binding presenter-view-proxy for different platforms? How you decide a problem with different presenters for platforms?
This limitation makes gwtp very inflexible. I think it is no way to replace view as it described in article because of mentioned drawbacks.

Brandon Donnelson

unread,
Dec 27, 2012, 1:08:35 AM12/27/12
to gwt-pl...@googlegroups.com
Good question. We've built an example showing one way to do it. You can see how we use the form factor logic to setup the Ginjector which controls the modules for the particular platform which means only the app for that platform is loaded. 

http://gwtp-sample-mobile.appspot.com/#!homePage - demo

Hope that helps, Brandon
Brandon

Evgeniy Ivlev

unread,
Dec 27, 2012, 3:34:10 AM12/27/12
to gwt-pl...@googlegroups.com
Brandon, unfortunately all your ginjectors (TabletGinjector, MobileGinjector, DesktopGinjector) inherit ClientGinjector and don't add its own presenters. So presenters for all platforms are identical. But we are case when tablet version of application is less functional and many desktop presenters shouldn't be binded for tablet app.


2012/12/27 Brandon Donnelson <brandon....@arcbees.com>
--
 
 

Brandon Donnelson

unread,
Dec 28, 2012, 9:22:07 PM12/28/12
to gwt-pl...@googlegroups.com
Ah, in our case we didn't want to duplicate the presenters. I see, you would maybe want to create a new presenter and bind that instead of using the same one in each module. 

Christian Goudreau

unread,
Jan 10, 2013, 9:53:57 AM1/10/13
to gwt-pl...@googlegroups.com
It's fairly easy to implement IF you have your own interface for the presenter. I'm not sure if there's already a utility function to do that, but you can do the bindings through Gin manually. 

I've done that in projects where the presenters was too different from one form factor to another.

Cheers,


--
 
 



--
Christian Goudreau

Christian Goudreau

unread,
Jan 10, 2013, 9:54:34 AM1/10/13
to gwt-pl...@googlegroups.com
FYI with the alpha of GWTP 0.8, there's still some work to do to make this really simple.
--
Christian Goudreau

Yachin Hsu

unread,
Jan 11, 2013, 1:49:18 AM1/11/13
to gwt-pl...@googlegroups.com
Hi, Thanks for sharing.

I am new to GWTP and mgwt. I am planning to follow the source code and see how it works.
After I get the project running in Eclipes, I got some missing classes error. How can I auto-generate those classes, ex. GetProductListAction.java. Thanks!

Christian Goudreau

unread,
Jan 13, 2013, 12:57:19 PM1/13/13
to gwt-pl...@googlegroups.com
Those are the annotations processors, if you want to have less problems, use another sample.

But doing a mvn clean install should do the trick (or package)


--
 
 



--
Christian Goudreau

Rob

unread,
Jan 29, 2013, 4:55:39 PM1/29/13
to gwt-pl...@googlegroups.com
Hi,

Isn't this related to (Issue 207) not being able to indicate which ginjector the GWTP proxy generator should use in the module definition file:

  <!-- This is required for Gwt-Platform Proxy's generator        -->
  <set-configuration-property name="gin.ginjector" value="com.gwtplatform.samples.mobile.client.gin.ClientGinjector" />

Cheers
Rob

Rob Ferguson

unread,
Jan 29, 2013, 6:17:00 PM1/29/13
to gwt-pl...@googlegroups.com
Hi,

Ahh, just back from holidays and browsing the new GWTP doco on github.

Some more reading to do but it looks like you have a new configuration property "gin.ginjector.modules", you generate the ginjector and the generated ginjector is used by GWTP's proxy generator?

Cheers
Rob

--
You received this message because you are subscribed to the Google Groups "GWTP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gwt-platform...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Christian Goudreau

unread,
Feb 9, 2013, 12:01:25 PM2/9/13
to gwt-pl...@googlegroups.com
Yes!

For the form factors, I've though of a solution that won't require any writing of new code in the code generator and it's by defining an Abstract presenter class that define the proxy inside it.

I still need to find out of the old proxy generator can pick up parents interfaces else you would be able to bind your gin modules depending on the form factors in bin in your gin modules

AbstractPresenter.toPresenterMobile
AbstractPresenter.toPresenterDesktop

This will ensure that only one provider <AbstractPresenter> is picked up by the ginjector generator.

There has been some changes also since my last answer :D
--
Christian Goudreau

Rob Ferguson

unread,
Feb 9, 2013, 6:04:26 PM2/9/13
to gwt-pl...@googlegroups.com
Hi Christian,

That would be great.

I know a lot of GWTP users are looking for the ability to use different Presenters (rather than shared Presenters) per form factor.

BTW, one of my customers asked me about this so I'll ask them if they are interested in donating to GWTP to fund this piece of work. Could you raise a new issue/change request that I could point them to?

Cheers
Rob

Christian Goudreau

unread,
Feb 11, 2013, 5:05:24 PM2/11/13
to gwt-pl...@googlegroups.com
Gladly! There's still a piece of investigation because I really think that no change will be needed since the new Ginjector generator has been added, but rather it needs to be clearly documented as to how to do it within gwtp 1.0

Christian Goudreau

unread,
Feb 11, 2013, 5:13:48 PM2/11/13
to gwt-pl...@googlegroups.com
Here's one issue related to this:

We already have something for this that is working in one of our private demo project. We'll be adding it to GWTP soon.

And this issue:

Cheers,
--
Christian Goudreau

Rob Ferguson

unread,
Feb 11, 2013, 5:56:48 PM2/11/13
to gwt-pl...@googlegroups.com
Thanks Christian.

I posted a comment to Issue 158 and I will follow up with my customer re funding this piece of work.
Reply all
Reply to author
Forward
0 new messages