Re: Re: Re: Re: Re: Re: Re: fr-set-label for fr:autocomplete in an XBL component

Posted by Erik Bruchez on
URL: https://discuss.orbeon.com/fr-set-label-for-fr-autocomplete-in-an-XBL-component-tp2916972p3044019.html

Ethan,

I had a look at this and it is definitely a bug: the destination
control, in general, is not found when an event is dispatched from a
local model.

Now specifically dispatching an event to a control upon
xforms-model-construct-done in an local model will typically not work,
because:

* the local model is initialized when control representing the the XBL
binding is initialized
* at that time the nested controls are not yet created

So the event will not reach its destination anyway.

This is consistent with what happens at the top-level: controls are
not available upon xforms-model-construct-done.

As a workaround you could instead, upon xforms-enabled of a local
control, dispatch an event to the model that will cause its
initialization, e.g.:

<xf:group ...>
  <xf:dispatch ev:event="xforms-enabled" ev:target="#observer"
name="my-initialization-event" target="my-local-model"/>

Can this work for you?

It would be better I think to have an event dispatched to the model
once the subtree of controls that can see that model is fully
initialized. Something like xforms-ready (which is not such a good
event to use in this case I think), or another custom event, like
xxforms-model-scoped or something like that.

Any thoughts?

-Erik

On Wed, Nov 10, 2010 at 6:43 PM, Alessandro Vernet <[hidden email]> wrote:

> Ethan,
>
> In this case, for what I can see, the issue is not with the
> xforms-model-construct-done, but with the <xforms:dispatch
> target="subject-autocomplete-control" name="fr-set-label">, which
> apparently can't find the control. I illustrated the situation here:
>
> http://forge.ow2.org/tracker/download.php/168/350207/315616/2227/Dispatch%20from%20model%20to%20control.png
>
> And I created a bug for this; Erik will be investigating it, and will
> let us know what he finds. For reference, the bug is:
>
> http://forge.ow2.org/tracker/index.php?func=detail&aid=315616&group_id=168&atid=350207
>
> Alex
>
> On Wed, Nov 10, 2010 at 4:20 PM, Ethan Gruber <[hidden email]> wrote:
>> Alex,
>>
>> This may be of some help, but a simple test with an <fr:autocomplete>
>> embedded directly in the form rather than as a called XBL component has
>> revealed that the label does not get set with xforms-model-construct-done,
>> but only xforms-ready.
>>
>> Ethan
>>
>> On Thu, Oct 28, 2010 at 3:12 PM, Ethan Gruber <[hidden email]> wrote:
>>>
>>> Hi Alex,
>>>
>>> I believe I have done this in the way that you have described, so I have
>>> included a form.  I can add repeatable subjects and the Solr querying works
>>> fine for autocomplete.  It's just that set-label doesn't work on
>>> xforms-model-construct-done in my code.
>>>
>>> The form queries a server at localhost, but this isn't important as I have
>>> already populated a test model with a value to load.
>>>
>>> Thanks for your help,
>>> Ethan
>>>
>>> On Sat, Oct 23, 2010 at 1:48 PM, Alessandro Vernet <[hidden email]>
>>> wrote:
>>>>
>>>> Ethan,
>>>>
>>>> Yes, xforms-model-construct-done is called in your XBL local model.
>>>> And yes, you can dispatch an event to a control inside your XBL
>>>> component, referring to that control by id. You need to make sure that
>>>> the control in a section of your XBL which is in inner scope
>>>> (xxbl:scope="inner"), as your XBL model is always in inner scope.
>>>>
>>>> If this doesn't work, I would setup debugging for development (see
>>>> link below, if you don't already have this setup), and look at exactly
>>>> what is happening the sequence of events in the log. If your dispatch
>>>> has no effect because Orbeon Forms can't find the specified id, the
>>>> log will tell you about it.
>>>>
>>>>
>>>> http://wiki.orbeon.com/forms/doc/developer-guide/xforms-logging#TOC-Development-configuration
>>>>
>>>> And of course, if you have a simple and reproducible case, we can also
>>>> look at it, if this can help.
>>>>
>>>> Alex
>>>>
>>>> On Fri, Oct 15, 2010 at 11:25 AM, Ethan Gruber <[hidden email]>
>>>> wrote:
>>>> > Am I correct in assuming that the xforms-model-construct-done action
>>>> > should
>>>> > be called in the local xforms:model within the XBL component?
>>>> >
>>>> > I tried the following:
>>>> >
>>>> > <xforms:action ev:event="xforms-model-construct-done">
>>>> >   <xforms:dispatch target="subject-autocomplete-control"
>>>> > name="fr-set-label">
>>>> >     <xxforms:context name="label" select="'test'"/>
>>>> >    </xforms:dispatch>
>>>> > </xforms:action>
>>>> >
>>>> > But it isn't setting the label to 'test'.  Is something missing?
>>>> >
>>>> > Thanks,
>>>> > Ethan
>>>> >
>>>> >
>>>> >
>>>> > On Wed, Oct 6, 2010 at 9:56 PM, Alessandro Vernet <[hidden email]>
>>>> > wrote:
>>>> >>
>>>> >> Hi Ethan,
>>>> >>
>>>> >> First, xforms-ready is intentionally not supported on models of XBL
>>>> >> components. As you found out, you should use
>>>> >> xforms-model-construct-done in that case (an in general, in most cases
>>>> >> it makes more sense to use xforms-model-construct-done). This is
>>>> >> documented on:
>>>> >>
>>>> >>
>>>> >>
>>>> >> http://wiki.orbeon.com/forms/doc/developer-guide/xbl-components-guide#TOC-Construction-and-destruction-of-loc
>>>> >>
>>>> >> Second, you are doing a <xforms:dispatch target="$binding">. The value
>>>> >> of the "target" attribute is expected to be an id (not an XPath
>>>> >> expression returning a node to which a control is bound). So in your
>>>> >> case, if you want to dispatch this to the <fr:autocomplete>, you can
>>>> >> try: <xforms:dispatch target="subject-autocomplete-control">.
>>>> >>
>>>> >> You'll let us know how this works for you,
>>>> >>
>>>> >> Alex
>>>> >>
>>>> >> On Fri, Oct 1, 2010 at 1:06 PM, Ethan Gruber <[hidden email]>
>>>> >> wrote:
>>>> >> > As a followup, I noticed that xforms-ready isn't supported in local
>>>> >> > XBL
>>>> >> > models, so I switched to using xforms-model-construct-done.  I can
>>>> >> > write
>>>> >> > a
>>>> >> > test value to a test instance, but I'm not sure how to access the
>>>> >> > value
>>>> >> > of
>>>> >> > the fr:autocomplete bound by $binding from within the local model.
>>>> >> >
>>>> >> > I wanted to try testing setting the label with a test value in the
>>>> >> > mean
>>>> >> > time.  The following is in the local model for my XBL component:
>>>> >> >
>>>> >> > <xforms:action ev:event="xforms-model-construct-done">
>>>> >> >   <xforms:dispatch target="subject-autocomplete-control"
>>>> >> > name="fr-set-label">
>>>> >> >     <xxforms:context name="label" select="'test'"/>
>>>> >> >   </xforms:dispatch>
>>>> >> > </xforms:action>
>>>> >> >
>>>> >> > It has no effect on setting the label.  I'm kind of lost.  I'm sure
>>>> >> > it
>>>> >> > is
>>>> >> > theoretically possible to set the label for each fr:autocomplete on
>>>> >> > xforms-model-contruct-done, but I'm not entirely sure of the syntax.
>>>> >> >
>>>> >> > Thanks for the help,
>>>> >> > Ethan
>>>> >> >
>>>> >> > On Fri, Oct 1, 2010 at 10:49 AM, Ethan Gruber <[hidden email]>
>>>> >> > wrote:
>>>> >> >>
>>>> >> >> I'm finally getting around to doing the smart thing and moving my
>>>> >> >> autocomplete controls into XBL components to better facilitate
>>>> >> >> repeatability
>>>> >> >> within my form.  The transition is nearly complete (the dynamic
>>>> >> >> itemset
>>>> >> >> is
>>>> >> >> populated based on queries that the user types into the
>>>> >> >> fr:autocomplete
>>>> >> >> text
>>>> >> >> input), but I haven't quite figured out how to set the label of the
>>>> >> >> XBL
>>>> >> >> component when the document reloads in the form.
>>>> >> >>
>>>> >> >> Before the change to XBL, the code to set the labels looked
>>>> >> >> something
>>>> >> >> like
>>>> >> >> this:
>>>> >> >>
>>>> >> >> <xforms:action ev:event="xforms-ready">
>>>> >> >>   <xforms:action xxforms:iterate="//subject">
>>>> >> >>     <xxforms:variable name="name" select="name()"/>
>>>> >> >>     <xforms:setindex repeat="{concat($name, '-repeat')}"
>>>> >> >> index="position()"/>
>>>> >> >>     <xforms:dispatch target="{concat($name,
>>>> >> >> '-autocomplete-control')}"
>>>> >> >> name="fr-set-label">
>>>> >> >>       <xxforms:context name="label"
>>>> >> >> select="normalize-space(context())"/>
>>>> >> >>     </xforms:dispatch>
>>>> >> >>   </xforms:action>
>>>> >> >> </xforms:action>
>>>> >> >>
>>>> >> >> This action is defined in the model for my form.  It doesn't
>>>> >> >> successfully
>>>> >> >> set the label of the fr:autocomplete contained in XBL.
>>>> >> >>
>>>> >> >> In my test form, I am calling the new component with this:
>>>> >> >>
>>>> >> >> <xforms:repeat nodeset="subject" id="subject-repeat">
>>>> >> >>   <eaditor:subject-autocomplete ref="."/>
>>>> >> >> </xforms:repeat>
>>>> >> >>
>>>> >> >> Attached is the XBL component.  It contains a model, but it seems
>>>> >> >> that
>>>> >> >> <xforms:action ev:event="xforms-ready"> does not work in that
>>>> >> >> model.
>>>> >> >> Since
>>>> >> >> the above xforms:action does not set the label of the component
>>>> >> >> when
>>>> >> >> embedded into the model in my test form, I'm not quite sure where
>>>> >> >> the
>>>> >> >> problem lies or potential workarounds.
>>>> >> >>
>>>> >> >> Help would be greatly appreciated,
>>>> >> >> Ethan
>>>> >> >
>>>> >> >
>>>> >> >
>>>> >> > --
>>>> >> > You receive this message as a subscriber of the [hidden email]
>>>> >> > mailing
>>>> >> > list.
>>>> >> > To unsubscribe: mailto:[hidden email]
>>>> >> > For general help: mailto:[hidden email]?subject=help
>>>> >> > OW2 mailing lists service home page: http://www.ow2.org/wws
>>>> >> >
>>>> >> >
>>>> >>
>>>> >>
>>>> >>
>>>> >> --
>>>> >> Orbeon Forms - Web forms, open-source, for the Enterprise -
>>>> >> http://www.orbeon.com/
>>>> >> My Twitter: http://twitter.com/avernet
>>>> >>
>>>> >>
>>>> >> --
>>>> >> You receive this message as a subscriber of the [hidden email]
>>>> >> mailing
>>>> >> list.
>>>> >> To unsubscribe: mailto:[hidden email]
>>>> >> For general help: mailto:[hidden email]?subject=help
>>>> >> OW2 mailing lists service home page: http://www.ow2.org/wws
>>>> >>
>>>> >
>>>> >
>>>> >
>>>> > --
>>>> > You receive this message as a subscriber of the [hidden email]
>>>> > mailing
>>>> > list.
>>>> > To unsubscribe: mailto:[hidden email]
>>>> > For general help: mailto:[hidden email]?subject=help
>>>> > OW2 mailing lists service home page: http://www.ow2.org/wws
>>>> >
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Orbeon Forms - Web forms, open-source, for the Enterprise -
>>>> http://www.orbeon.com/
>>>> My Twitter: http://twitter.com/avernet
>>>>
>>>>
>>>> --
>>>> You receive this message as a subscriber of the [hidden email] mailing
>>>> list.
>>>> To unsubscribe: mailto:[hidden email]
>>>> For general help: mailto:[hidden email]?subject=help
>>>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>>>
>>>
>>
>>
>>
>> --
>> You receive this message as a subscriber of the [hidden email] mailing
>> list.
>> To unsubscribe: mailto:[hidden email]
>> For general help: mailto:[hidden email]?subject=help
>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>
>>
>
>
>
> --
> Orbeon Forms - Web forms, open-source, for the Enterprise -
> http://www.orbeon.com/
> My Twitter: http://twitter.com/avernet
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws