Best Design Pattern for widgets

76 views
Skip to first unread message

Sebastian Coronado A.

unread,
Jan 7, 2011, 11:36:25 PM1/7/11
to Google Web Toolkit
Hello I was checking MVP explanation, it works for the whole
application but what if I want to create a single widget that does not
need transitions from one view to another. For example what design
pattern would you use to create a rich text editor.
regards

Gal Dolber

unread,
Jan 8, 2011, 12:08:28 AM1/8/11
to google-we...@googlegroups.com
mmm...
  1. Use Composite!
  2. Reduce to the minimum the number of widgets that compose your new widget (Bulk html rendering + top level event capturing). 
  3. Learn all you can from native gwt widgets.
  4. Make good use of interfaces [HasText, HasHTML, Foccusable.. everything you can find under com.google.gwt.user.client.ui]
  5. UiBinder support! Design pojo-like widgets.
  6. Use gwt's shared events when possible [SelectionEvent, ValueChangeEvent, .... (under com.google.gwt.event.logical.shared)]
  7. ~~~do not create your own event system? :-J
  8. ~~~do not create your own panels and layout system? :-J
This session is really recommendable: http://www.youtube.com/watch?v=7x4hun_Kqks

Best


--
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.




--
Guit: Elegant, beautiful, modular and *production ready* gwt applications.

http://code.google.com/p/guit/




A. Stevko

unread,
Jan 8, 2011, 12:20:32 AM1/8/11
to google-we...@googlegroups.com
I totally agree - extending Composite is the way to go.
Composite Widgets are nice for encapsulating & localizing all the CRUD associated with a single object like your text editor.
RichTextToolbar,java is a stock example of a widget that attaches itself to your RichTextArea

-- A. Stevko
===========
"If everything seems under control, you're just not going fast enough." M. Andretti





Thomas Broyer

unread,
Jan 8, 2011, 6:09:09 AM1/8/11
to google-we...@googlegroups.com
In addition to what others already said, you can use MVP inside your widget, so that you can easily unit-test your logic. Have a look at com.google.gwt.user.cellview.client.AbstractHasData (the base class for CellList and the like) which uses this pattern.

Sebastian Coronado A.

unread,
Jan 8, 2011, 12:02:37 PM1/8/11
to Google Web Toolkit
Composite is nice but my widget has like 5 widgets, it looks messy.

@Thomas
thanks I will take a look


On 8 ene, 06:09, Thomas Broyer <t.bro...@gmail.com> wrote:
> In addition to what others already said, you can use MVP *inside* your
Reply all
Reply to author
Forward
0 new messages