hi *,
thanks to the input from anja lehmann i've built a new sample showing
one approach for building a wizard in XForms. the new sample may be
checked out from cvs under the name 'wizard-with-relevant.xhtml' and
should be run with latest cvs code. (a copy is attached for the curious)
first of all let me say that i don't claim this approach to be the only
possible or best. it's just one approach that solves some problems
you're facing when implementing wizards - and as i'm a bit proud to say
- one without any additional extensions in the code or stylesheets,
built solely with XForms.
what are the the problems when building a wizard?
a wizard is normally used to collect data from the user and breaks the
needed UI for collecting those data into chunks for easier consumption
by the user. while stepping through the pages the current page data
normally have to be validated before proceeding to the next step.
the problem with this 'validation-in-chunks' is that the pages don't
necessarily match the models they are filling but XForms can only
validate complete models (for good reasons btw). it certainly wouldn't
be a good choice to make models and UI match or to be forced to do that.
after discussing this with Uli we came to the conclusion that switch is
not the construct of choice for wizards although you might be drawn to
this belief. switch is very static and cannot 'interact' with
instance-data but the 'validation-in-chunks' problem is data-related.
a better granularity of control is given through the relevant modelitem
property. remember that non-relevant nodes are not displayed (or to be
precise their UI) nor considered for validation! this is essential for
the sample to work. this way we can suppress unwanted validation of data
on pages that the user hasn't visited already and therefore didn't even
had a chance to fill in.
to really understand the sample you should study the source but here a
few hints to understand the approach.
- the sample uses a helper instance to control the wizard. this has the
nice effect that the actual instance data structure is not affected by
the wizard.
- every page is wrapped into a group which is bound to this 'controller'
instance and uses a relevant attribute to steer the display and hiding
of pages.
- every group/page is bound to its own node in the helper instance to
allow separate switching of relevance.
- to switch between pages a submit replace=none is dispatched which
leads to validation of the relevant data (only page1). after that the
page relevance is updated resulting in the next page being displayed and
the last being hidden. this always switched the 'window of data' being
relevant and considered for validation.
- at final submit we have another problem to solve: cause the submission
only sends relevant data to the target we would actually submit nothing
when not making the previous pages relevant before (see at the end of
the sample)
and before you ask: i'm not sure why the recalculate and refresh actions
are necessary to switch pages. there may still be a deficiency in our
setvalue action maybe...
thanks to the interested how made it up to here. feedback on this topic
very appreciated.
Joern
wizard-with-relevant.xhtml
Description: application/xhtml
|
Try Searching:
servers, voip, java, networking, microsoft ...
|
|
|
|