and more get into problems with Browser Event Handling (Click,
MouseOut/Over, etc.). And connected with that some other things too. I
could be that my structure is no true MVP, and maybe that's the cause
for my problems?! But have a look yourself:
I have a News section. It consists of
- NewsPresenter + Display
- NewsItemPresenter + Display + Model
The first little question: Where in the MVP structure I should fetch
the data from the server? Inside the presenter or should I write some
kind of controller that handles ONLY the server connection for news?
(For instance I could say: 'give me all news' or 'give me the next 5
news after id 5' and 'update id 3 with the following model'). Actually
it's all inside the NewsPresenter, it works, but it's bad for the
overview...
Now my real problems:
First all news I'd like to display a fetched from the server (or
cache). Then the NewsPresenter has a HashMap<NewsItemId,
NewsItemPresenter>. It takes each NewsItemModel and calls 'new
NewsItemPresenter(model)' and puts it into the HashMap. So I have a
cache which is pretty handy. Afterwards the NewsPresenter attaches
those NewsItemPresenters to the content area of the NewsDisplay. I
think that's pretty straight forward.
Now each NewsItemDisplay has Click/MouseOver/MouseOut Handlers. And as
Google told us, it's better to have a single Handler than one Handler
for each item. Right now every NewsItemDisplay has it's own Handlers
and tells it's presenter (via well designed Interface) which button
was clicked. But I'd like to have the NewsPresenter (or NewsDisplay)
to handle such things with a single EventHandler. Sure I could add the
ClickHandler to the NewsDisplay but then I don't know which of my
items was clicked and even harder: Which button inside of an item was
clicked.
It would be pretty cool, if someone could give me some advise (or
example Code) on how to achieve this. :)
--
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-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment