Communicating between gwt composites

55 views
Skip to first unread message

jax

unread,
Dec 16, 2009, 2:01:23 AM12/16/09
to Google Web Toolkit
HI

I have a questions about communication in GWT and java in general.

In an effort to better modularize my application I have made a number
of different composites. I then have a main application that links
together all the composites.

The problem comes when I need to communicate between composites, for
example change an image in a composite based on an event in another
composite.

They way I have don this now is by passing "this" to every composite
constructor and saving it as parent. I also have methods that allow
me to get the children of a composite. Then in each composite I have
a getCompositeParent() method that will allow me to go further down
the composite tree.

For example:

parent.getCompositeParent().getCompositeParent().getNamesComposite
().getName().setText("hello");

This seems a bit unwieldy. Is this the normal way of doing things in
JAVA?

rjcarr

unread,
Dec 16, 2009, 3:13:24 AM12/16/09
to Google Web Toolkit
This isn't so much a java question but a software design question.

There are many ways, or patterns, to accomplish what you're after.
I'd recommend that you read the book Design Patterns to learn more. I
think what you're after is the Observer pattern.

Good luck!

Grant

unread,
Dec 16, 2009, 4:12:30 AM12/16/09
to Google Web Toolkit
What you probably want is an Event Bus.

There is a great video available, google for 'gwt mvp'. It is well
worth a watch

Grant

Robert J. Carr

unread,
Dec 16, 2009, 4:40:32 AM12/16/09
to google-we...@googlegroups.com
Isn't the event bus just an implementation of the Observer pattern?
> --
>
> You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
>
>
>

Anirban Talukdar

unread,
Dec 16, 2009, 2:20:02 AM12/16/09
to google-we...@googlegroups.com
Sorry Jax,

It is "mediator pattern", I skipped it .

Thanks & Regards
Anirban Talukdar

On Wed, Dec 16, 2009 at 12:39 PM, Anirban Talukdar <talukdar...@gmail.com> wrote:
I Feel Facade design pattern will help you solving the issue. This is basically a design issue.

Thanks & Regards
Anirban Talukdar


Anirban Talukdar

unread,
Dec 16, 2009, 2:09:20 AM12/16/09
to google-we...@googlegroups.com
I Feel Facade design pattern will help you solving the issue. This is basically a design issue.

Thanks & Regards
Anirban Talukdar

On Wed, Dec 16, 2009 at 12:31 PM, jax <jack...@gmail.com> wrote:

jax

unread,
Dec 21, 2009, 3:53:26 AM12/21/09
to Google Web Toolkit
OK thanks

looks like I need to find a good book on design patterns.


On Dec 16, 2:09 pm, Anirban Talukdar <talukdar.anir...@gmail.com>
wrote:


> I Feel Facade design pattern will help you solving the issue. This is
> basically a design issue.
>
> Thanks & Regards
> Anirban Talukdar
>

> On Wed, Dec 16, 2009 at 12:31 PM, jax <jackma...@gmail.com> wrote:
> > HI
>
> > I have a questions about communication in GWT and java in general.
>
> > In an effort to better modularize my application I have made a number
> > of different composites.  I then have a main application that links
> > together all the composites.
>
> > The problem comes when I need to communicate between composites, for
> > example change an image in a composite based on an event in another
> > composite.
>
> > They way I have don this now is by passing "this" to every composite
> > constructor and saving it as parent.  I also have methods that allow
> > me to get the children of a composite.  Then in each composite I have
> > a getCompositeParent() method that will allow me to go further down
> > the composite tree.
>
> > For example:
>
> > parent.getCompositeParent().getCompositeParent().getNamesComposite
> > ().getName().setText("hello");
>
> > This seems a bit unwieldy.  Is this the normal way of doing things in
> > JAVA?
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-we...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>

FKereki

unread,
Dec 21, 2009, 8:28:22 AM12/21/09
to Google Web Toolkit
This sounds like you could use an Event Bus, also called "Event
Collaboration" pattern; see http://martinfowler.com/eaaDev/EventCollaboration.html
for more on it.

Basically, the idea is that whenever something "interesting" happens,
a Composite raises an event, which all other composites get a chance
to process. Most composites will just simply "let it pass", but those
who find it relevant, can update themselves.

Reply all
Reply to author
Forward
0 new messages