Re: Need for a 'global instance' function [was Re: i18n, componentized forms and multiple models]

Mark,

A question related to your use of models to provide modular components: 
do you have a mechanism by which you can call a method on the model 
(send an event) and pass it an instance? For example, if your model 
implements a "save" function into eXist, ideally you would try to 
achieve something like this (using an OO notation):

   my-model.save(instance('my-instance'))

Now I see how you dispatch a "save" event to the model with id 
"my-model", but how do you pass it data? Do you use event context 
information?

-Erik

Mark Birbeck wrote:
> 
> Hi Erik,
> 
>> But wouldn't allowing this function to be called from a model encourage
>> breaking encapsulation? Wouldn't events be enough as a mechanism to
>> communicate between models?
>>
>> For use within controls I don't disagree though. Maybe the instance()
>> function could simply take an optional second parameter, that would
>> indicate if the search for instances should be global:
>>
>> [...]
> 
> We felt that having a different function made it clearer that we were
> really doing a lookup, rather than establishing a connection between
> the models. The point here is that we actually *don't* want a
> 'connection' between the models, since this 'leak' would then require
> longer rebuilds. But we *do* want to be able to reference data in
> other models, such as when using an instance as a source of templates
> for xf:insert.
> 
> There are actually many situations in XForms where you use a value in
> a calculation on a 'per-use' basis, such as in xf:setvalue or
> xf:insert, and since this creates no dependency, it's not going to
> hurt to be able to get data from other models for these actions.
> 
> As it happens, in most of our stuff we don't have expressions that mix
> models within one XPath statement; what we try to do is use our
> encapsulation techniques, and just copy out the data we need with
> setvalue or insert. So far we've kept our use of globalInstance() to
> that, and it has worked pretty well.
> 
> Regards,
> 
> Mark
> 


-- 
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/

Received on Wednesday, 26 July 2006 14:42:36 UTC