Pectin with UiBinder

20 views
Skip to first unread message

Daniel Bell

unread,
Jun 6, 2010, 2:43:06 AM6/6/10
to GWT Pectin
Hi Andrew et al,
I've just started using GWT Pectin, and I'm very impressed by how
easily I could integrate it with my project, how conducive the design
is to unit testing, and how in touch Pectin is with the GWT philosophy
of having independently useful parts. Congratulations on a great
framework so far!
I noticed on the Future Features and Design Ideas page on the wiki
(http://code.google.com/p/gwt-pectin/wiki/
FutureFeaturesAndDesignIdeas) that you were thinking about integrating
gwt-pectin with UiBinder. I've been making heavy use of UiBinder
recently, and was thinking of attempting something like that myself,
to make bean binding quicker with UiBinder forms. Do you have any
thoughts on how you would like it to work? I have a few of my own, but
I'm keen to find out your thoughts so I could contribute back to the
project.
Thanks in advance,
Daniel

Andrew

unread,
Jun 6, 2010, 9:10:01 PM6/6/10
to GWT Pectin
Hi Daniel,

Direct support for UiBinder would be an enormous improvement and any
contributions greatly appreciated. Initially I was hoping I could
have do something like `interface MyFormBinder extends
UiBinder<Widget, MyFormModel>` and then write markup perhaps somthing
like:

<g:FlowPanel pectin:showWhen="someBooleanField">
<g:TextBox pectin:boundTo="firstName">
<x:someWidget pectin:displayValidationOf="firstName">
</g:FlowPanel>

But this is all completely off the top of my head and involves
vigorous arm waving. I haven't thought through the implications or
considered how it might (or even if it can) be implemented.

This approach also requires that UiBinder supports custom attribute
parsers which I've only very briefly looked at. I noticed a while
back there were some attempts to make the UiBinder more pluggable by
other developers but this was focused on element parsers. I'm not
sure what the current state of play is but here's some links I came
across:
http://groups.google.co.uk/group/google-web-toolkit-contributors/browse_thread/thread/4d79f729030527c5
http://cafebab3.blogspot.com/2009/12/gwt-2-declarative-layout-beyond.html

What were your ideas?

Cheers
Andrew

Andrew

unread,
Jun 6, 2010, 10:02:54 PM6/6/10
to GWT Pectin
And after a few minutes more thought, I'd probably want to bind at the
controller/presenter level. It doesn't make that much difference to
the previous example except that it requires nested paths (e.g.
boundTo="model.firstName" etc).

public class MyController {
interface MyBinder extends UiBinder<Widget,MyController>{}

MyFormModel model = ...;
ValueModel<Boolean> editingFirstName = ...;
UiCommand saveCommand = ...;
}

<g:FlowPanel pectin:showWhen="editingFirstName">
<g:TextBox pectin:boundTo="model.firstName">
<x:SomeValidationDisplayWidget
pectin:displayValidationOf="model.firstName"/>
<g:Button pectin:boundTo="saveCommand">Save</g:Button>
</g:FlowPanel>

Cheers

On Jun 7, 11:10 am, Andrew <andrew.piet...@gmail.com> wrote:
> Hi Daniel,
>
> Direct support for UiBinder would be an enormous improvement and any
> contributions greatly appreciated.  Initially I was hoping I could
> have do something like `interface MyFormBinder extends
> UiBinder<Widget, MyFormModel>` and then write markup perhaps somthing
> like:
>
> <g:FlowPanel pectin:showWhen="someBooleanField">
>    <g:TextBox pectin:boundTo="firstName">
>    <x:someWidget pectin:displayValidationOf="firstName">
> </g:FlowPanel>
>
> But this is all completely off the top of my head and involves
> vigorous arm waving.  I haven't thought through the implications or
> considered how it might (or even if it can) be implemented.
>
> This approach also requires that UiBinder supports custom attribute
> parsers which I've only very briefly looked at.  I noticed a while
> back there were some attempts to make the UiBinder more pluggable by
> other developers but this was focused on element parsers.  I'm not
> sure what the current state of play is but here's some links I came
> across:http://groups.google.co.uk/group/google-web-toolkit-contributors/brow...http://cafebab3.blogspot.com/2009/12/gwt-2-declarative-layout-beyond....

Daniel Bell

unread,
Jun 7, 2010, 12:31:16 AM6/7/10
to gwt-pecti...@googlegroups.com
Hi Andrew,
Thanks for the quick reply. My initial thoughts were actually very similar to your second example, so I'm glad we're on the same wavelength. Here's what I was thinking, in the form of a slightly modified version of your example:

    <ui:with field="resources" type="com.mycompany.MyResources"/>
    <ui:with field="model" type="com.mycompany.MyViewModel"/>
    <ui:with field="editingFirstName" type="com.pietschy.gwt.pectin.client.value.ValueModel"/>
    <ui:with field="saveCommand" type="com.pietschy.gwt.pectin.client.command.UiCommand"/>
    <g:FlowPanel p:showWhen="{editingFirstName}">
        <g:TextBox p:boundTo="{model.firstName}" p:watermark="{resources.firstNameWatermark}">
        <pv:ValidationDisplayPanel p:displayValidationOf="{model.firstName}"/>
        <g:Button p:boundTo="{saveCommand}">Save</g:Button>
    </g:FlowPanel>

As you can see, it's quite similar to your idea, except it uses the <ui:with /> elements to either use the fields with those names contained in the bound MyController class (annotated with @UiField, as normal), or automatically instantiate (or GWT.create() ) them. I'm not sure whether there is a way yet to add custom attribute parsers, but if not, I'd planned on switching a custom PectinUiBinderGenerator for the standard the UiBinderGenerator, in the same way mentioned in Daniel Dietrich's comment on the second link you sent me. What do you think?

Cheers,
Daniel

Andrew

unread,
Jun 7, 2010, 2:23:42 AM6/7/10
to GWT Pectin
Yep, that looks great.

As a small note, another thing that would be nice is to support
`boundTo` properties that are either fields, getters or regular
methods. E.g. the following would bind to saveCommand.active():

<g:Label p:showWhen="saveCommand.active"/>Saving...</g:Label>

Thanks for looking into this, I greatly appreciate it.

Cheers
Andrew
> >http://groups.google.co.uk/group/google-web-toolkit-contributors/brow.....
> > ..

Daniel Bell

unread,
Jun 7, 2010, 5:07:24 AM6/7/10
to gwt-pecti...@googlegroups.com
No problem. I'll have a look at the current support for custom attribute parsing, and then get started.
Thanks for your help,
Daniel

Andrew

unread,
Jun 17, 2010, 8:54:08 PM6/17/10
to GWT Pectin
There's a publicly accessible wave with initial ideas and usage
examples at the following for those interested.

https://wave.google.com/wave/?nouacheck&pli=1#minimized:search,restored:wave:googlewave.com%252Fw%252BCE2z1X_0A

On Jun 7, 7:07 pm, Daniel Bell <daniel.r.b...@gmail.com> wrote:
> No problem. I'll have a look at the current support for custom attribute
> parsing, and then get started.
> Thanks for your help,
> Daniel
>
Reply all
Reply to author
Forward
0 new messages