Thursday, January 31, 2013

Re: Cancel CellList selection



On Tuesday, January 29, 2013 6:43:11 PM UTC+1, BM wrote:
I was looking something similar and your example is perfect. I am going with approach of having my custom SingleSelectionHandler i.e PromptingSelectionModel . My view is more like GWT Showcase CellList-DetailForm example. If I click on my cell, my code populates the form elements. My Form is a separate GWT custom widget FormAWidget with its own presenter FormAPresenter. 

So with that being said, I probably will be storing a variable "hasUnsavedChanged" in ClientFactory which gets updated whenever my form data is changed. How do I get that variable inside my PromptingSelectionModel class so that I can check that variable in my overridden setSelected method? Since I use GWT MVP structure my ViewA holds declaration of CellList and PromptingSelectionModel. The ActivityA has reference to ClientFactory, the only way I can think of is passing the ClientFactory to my ViewA class with setClientFactory(ClientFactory cf) and pass that ClientFactory object to PromptingSelectionModel constructor. I don't like the idea of my views now having reference of ClientFactory.

"ClientFactory" (if you copied it form the Dev Guide) is supposed to be about "manual dependency injection". You shouldn't pass it around (if you were using a JSR330 DI framework or similar, such as GIN, you wouldn't even pass it to the activities, you'd instead inject a Provider<HelloView>). If you happen to need it in the view, then give it to the view when it's constructed (the view is constructed by the ClientFactory, right?)

That said, I believe the selection model should live in the presenter: it's part of the "presentation logic".

Please advise if you can see any better way of doing this.


Avoid global shared state. Don't put "hasUnsavedChanges" in your ClientFactory. That information belongs to your form (and in this case, its presenter). Then inject objects into each other as needed so they have access to the information.

 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment