Re: Use cases for multiple models

Erik,

When I first started using XForms I tended to use multiple models as  
a convenient packaging device. So I tried to keep "business data +  
rules" in one model, captions and values for enumerations in another,  
and instances used to manage presentation logic/control in a third.  
It just seemed a neat way of working, and I assumed it was one of the  
reasons for allowing multiple models in one containing document. I  
know a number of other form authors have independently done exactly  
the same thing. However, I subsequently learned that I was in error  
to do this, and that the favoured approach of the WG was one form,  
one model. By-the-way, is this actually stated anywhere in the rec.?  
If not, should it be? I couldn't find anything obvious, although it  
is hinted at in the section on multiple models in one containing  
document.

I actually quite like the idea of being able to logically group the  
constituent elements of a form by function, it could make things  
easier to read, write, maintain and reuse. Whether or not the  
grouping mechanism is the model I don't really mind. Anyway, until  
bind (or something akin) works properly and allows proper indirection  
(i.e. I can write application logic without having to refer directly  
to XML nodes, but can just refer to binds) then it isn't really  
possible to separate business data  and application logic/control  
because they are too interdependent.

For example, take the design pattern that MarkB published recently  
[http://skimstone.x-port.net/node/346] to break a repeat up into  
manageable pages. This requires a bind statement that refers directly  
to the instance with the data to be displayed in the repeat, and to  
an instance used to manage the repeat. Obviously the two need to be  
related to each other somehow, but it would be nice if it didn't have  
to be within the bind itself. Anyway, I am going off at a tangent.

Another possibility for multiple models in one form is MarkB and  
Raman's idea of using complete XForms as form controls. Obviously  
that isn't catered for at the moment, but it is a neat idea.

All the best

Mark

On 12 Jul 2006, at 14:12, Erik Bruchez wrote:

>
> All,
>
> I am wondering what use cases for multiple models XForms users have
> encountered.
>
> I personally have very rarely had the need for multiple models, and
> encountered issues when trying to use multiple models related to the
> XPath evaluation context in controls (for example once you are in the
> context of a model, the instance() function can only access instances
> from that model).
>
> But I still want to believe there must be good use cases out there, so
> don't be shy and please share :-)
>
> -Erik
>
> -- 
> Orbeon - XForms Everywhere:
> http://www.orbeon.com/blog/
>
>

Received on Thursday, 13 July 2006 08:58:56 UTC