Is it bad practice to use links like "#viewObject104" instead of eventBus.fireEvent(viewObjectEvent(id)) ?

29 views
Skip to first unread message

Drew Spencer

unread,
Feb 9, 2012, 12:05:58 PM2/9/12
to google-we...@googlegroups.com
Hi coders,

Hopefully the subject explains the question enough but here's a bit of background.

I have been using events for pretty much everything, but while searching for a better way than using ButonCell in my CellTable, I discovered that using SafeHtml I could generate an anchor with a token, which when clicked would add that token to the History. Then, my AppController would parse the token and load the correct presenter/view. Seems ok and works with the History system well.

I guess what I'm asking is: If my event's job was only to get an ID and then load a new presenter/view with that ID, does it need to exist or can I just bash a new item in the history from anywhere as long as my AppController can handle it?

Thanks as always,

Drew

KevMo

unread,
Feb 9, 2012, 1:42:58 PM2/9/12
to Google Web Toolkit
If you're just passing an ID, I think just using links is a lot better
than making events and listening for them. If you're passing an entire
object, then events are probably better to keep you from making
another call to the server.

I personally prefer links, because it also allows the user to open the
link in another window or tab.

Matias Costa

unread,
Feb 9, 2012, 5:15:40 PM2/9/12
to google-we...@googlegroups.com
> I personally prefer links, because it also allows the user to open the 
> link in another window or tab. 

And the history works

Drew Spencer

unread,
Feb 10, 2012, 6:52:09 AM2/10/12
to google-we...@googlegroups.com
Thanks Kev,

I think I'm getting the idea now, and should be at the point soon where I NEED to fire an event - like you say containing a proper object instead of just an id. I only found myself asking this question because I wanted to add the ID to the history token, so it seemed logical to do away with the event completely.

One other thing to ask though. Is it possible to have more than one onValueChange() in your application? I tried adding one to one of my presenters, set the presenter to implement ValueChangeHandler<String> but nothing. Is the whole point that you can only have one?

Cheers,

Drew

Drew Spencer

unread,
Feb 10, 2012, 6:52:50 AM2/10/12
to google-we...@googlegroups.com
I was adding a history token in a function being called by the event! So much boilerplate! Cheers
Reply all
Reply to author
Forward
0 new messages