Best practice

5 views
Skip to first unread message

AlexB

unread,
May 20, 2010, 2:53:57 AM5/20/10
to GWT Pectin
Hi all

I stumble across this library a few days ago and I am amazed at its
quality and beauty of approch.
I am quite new to gwt, coming from spring mvc and webflow with jsp
and jsf so forgive me if the question is naive.

I have a pojo representing my domain entity that contains about 100
fields.

The resulting forms have to take the form of wizards like screen, each
one with its own validation. In short, it is possible to move to the
next screen only if the currently visible fields have passed
validation.

Now my question: what is the best approach for a wizard like set of
screens?

I could have a singe model, and perform manual validations at each
step, or I could split my logic into several models (one per wizard
screen).

What is your advice? Is there any snippet that could give me some head
start?

Thank you in advance for your feedback and congrats again for this
wanderful library.


Alessandro





Andrew

unread,
May 20, 2010, 9:16:53 PM5/20/10
to GWT Pectin
Hi Alessandro,

Thanks for your compliments. Pectin has grown out of the great idea's
of others so I'm indebted to many others as well. Observable
ValueModels have been around a long time but in the rich client world
but they're not that common in tradtional web frameworks as far as I'm
aware (since rendering generally isn't 'live'). I think Wicket has a
similar notion but it's been quite a while since I looked at it.

I'd almost certainly create one form model for each wizard page, the
form model would then create fields relevant for it's page. I'd
probably keep the form model as an implementation detail of each page
(i.e. I wouldn't try and use a form model for my `wizard model`). The
exact design would depend on your requirements, i.e. if you don't need
any dynamic bahaviour (like previous & next buttons that enable and
disable automatically when the form data is valid) then you could get
away with simple methods like `boolean WizardPage.validate()`,
`WizardPage.commit()` etc that simply delegate to the form model.
Otherwise you could expose a value model from a method like
`ValueModel<Boolean> WizardPage.getValidModel()`. You could use this
in your wizard to update the buttons. You would need to update the
state of the your `validModel` when you get value change events or on
blur events. This behaviour isn't automatic yet (validate as you type
etc), there are some very initial design thoughts at
https://wave.google.com/wave/?nouacheck&pli=1#restored:wave:googlewave.com!w%252BvIXX8JY-A
but I haven't had the time to progress them at this point.

A quick google threw up a couple of GWT wizard libraries so you might
want to check those out too. I wrote one for Swing way back but I'd
do it a bit differently if I had my time over.

I'd be interested to know how pectin performs with so many fields,
I've performed a small amount of testing with the new SOYC tools but I
haven't used it on anything with that may fields.

Hope this helps.
Cheers
Andrew
Reply all
Reply to author
Forward
0 new messages