A simple general-purpose wizard [was RE: xforms for inhomogenous collections]

Hi Oliver,

You wrote:
> The way I see it, "relevance" in the context of the group element
refers
> to the "relevant" attribute of a bind element in the model. Is that
correct?
> If so, I do not yet understand how I (as a user of my application)
could
> specify a bind element that would lead to the desired effect. Could
you
> give me a hint?
>
> I guess, the simplest thing for my purpose would be something like the
following
> (with the example data in my last message). But as far as I can see,
this would
> be an extension.  Is that what you suggest?
>
>
>    <xforms:repeat ref="/record-set/record">
>      <hr/>
>
>      <xforms:group relevant="@type = 'author'">
>	<h2>An Author</h2>
>	<xforms:input ref="name">
>	  <xforms:label>Author Name</xforms:label>
>	</xforms:input>
>      </xforms:group>
>
>     <xforms:group relevant="@type = 'book'">
>	<h2>A Book</h2>
>	<xforms:input ref="title">
>	  <xforms:label>Book Title</xforms:label>
>	</xforms:input>
>     </xforms:group>
>
>    </xforms:repeat>

You are correct about using @relevant, but not in how it is used. It
should not be an attribute on a form control.

What you need to do is make use of the fact that binding model item
properties (MIPs) such as 'relevant' and 'readonly' to a nodeset results
in the value of those MIPs being forwarded to any user interface
components connected to the nodeset. This goes for xf:group and
xf:trigger, as much as it does for any other UI control.

So, for example, you could have a set of 'page' elements in an instance,
and then use a page number to enable one and disable the others:

    <xforms:bind nodeset="page" relevant="@id = /currentPage" />

Then you simply bind an xf:repeat or a series of xf:groups to these
elements. The following uses the xf:group approach, but if every page
had the same structure an xf:repeat would be even easier:

    :disabled { display: none; }
    xforms|group { display: block; }

    /* for formsPlayer */
    .disabled { display: none; }
    xforms\:group { display: block; }

    <xforms:group ref="page[1]">
        <h2><xforms:output ref="@title" /></h2>
        I'm the first page ...
    </xforms:group>

    <xforms:group ref="page[2]">
        <h2><xforms:output ref="@title" /></h2>
        ... and I'm the second.
    </xforms:group>

Now you simply change the value of 'currentPage' and the correct
xf:group becomes enabled, the others disabled.

An example including dynamic navigation triggers that use the same
technique, is attached. It is a generic 'wizard controller' that can be
used with any repeating sequence to drive the pages of the wizard. It
has been tested in formsPlayer.


Regards,

Mark


Mark Birbeck
CEO and CTO
x-port.net Ltd.

Download our 100% compliant XForms processor
From http://formsPlayer.com/

Received on Wednesday, 17 December 2003 15:04:22 UTC