Custom XBL component

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Custom XBL component

marek2608
Hi I am trying to build a new component using the tutorial: http://wiki.orbeon.com/forms/doc/developer-guide/xbl-components-guide

I'v created a file under /WEB-INF/resources/xbl/rpm/hyperlink.xbl
and coded the following contents:

<xbl:xbl xmlns:xhtml="http://www.w3.org/1999/xhtml"
         xmlns:xforms="http://www.w3.org/2002/xforms"
         xmlns:xs="http://www.w3.org/2001/XMLSchema"
         xmlns:ev="http://www.w3.org/2001/xml-events"
         xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
         xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
         xmlns:xbl="http://www.w3.org/ns/xbl"
         xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
         >

    <xbl:binding element="fr|hyperlink">
        <xbl:template>
            <xforms:group xbl:attr="model context ref bind" xxbl:scope="outer">
               
                <xbl:content includes="xforms|label,xforms|help,xforms|hint,xforms|alert"/>
                <xforms:trigger xmlns=""
                                appearance="minimal"
                                id="">
                    <xforms:action ev:event="DOMActivate">
                        <xforms:load ref="fr|hyperlink > xforms|label" show="new"/>
                    </xforms:action>
                </xforms:trigger>
            </xforms:group>
           
        </xbl:template>
    </xbl:binding>
</xbl:xbl>

And reference it in the form definition in the heading:
<xi:include href="oxf:/xbl/rpm/hyperlink/hyperlink.xbl" xxi:omit-xml-base="true"/>

When I add my component to the form definition in Form Builder:

                                <fr:hyperlink id="control-2-control" bind="control-2-bind">
                                    <xforms:label ref="$form-resources/control-2/label"/>
                                    <xforms:hint ref="$form-resources/control-2/hint"/>
                                    <xforms:help ref="$form-resources/control-2/help"/>
                                    <xforms:alert ref="$fr-resources/detail/labels/alert"/>
                                </fr:hyperlink>

And test run it, I get the following error:
Duplicate id found for effective id: control-2-control$xf-454

I'm not to sure where it comes from, what is it refering too?

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Custom XBL component

Grégoire Neuville
Hi,

The xforms:trigger control bears an id but is in outer scope in your
component. You cannot do that : every control with an id should be in
inner scope. So, you should end up with something like :

<xbl:template>
            <xforms:group xbl:attr="model context ref bind"
 xxbl:scope="outer">
                <xforms:group appearance="xxforms:internal" xxbl:scope="inner">
                     <xxforms:variable name="binding">
                         <xxforms:sequence select="." xxbl:scope="outer" />
                     </xxforms:variable>
                     <xforms:trigger  ref="$binding" id="myid">
etc...

Hope that helps,

On 14 December 2011 20:36, marek2608 <[hidden email]> wrote:

> Hi I am trying to build a new component using the tutorial:
> http://wiki.orbeon.com/forms/doc/developer-guide/xbl-components-guide
>
> I'v created a file under /WEB-INF/resources/xbl/rpm/hyperlink.xbl
> and coded the following contents:
>
> <xbl:xbl xmlns:xhtml="http://www.w3.org/1999/xhtml"
>         xmlns:xforms="http://www.w3.org/2002/xforms"
>         xmlns:xs="http://www.w3.org/2001/XMLSchema"
>         xmlns:ev="http://www.w3.org/2001/xml-events"
>         xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
>         xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
>         xmlns:xbl="http://www.w3.org/ns/xbl"
>         xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
>         >
>
>    <xbl:binding element="fr|hyperlink">
>        <xbl:template>
>            <xforms:group xbl:attr="model context ref bind"
> xxbl:scope="outer">
>
>                <xbl:content
> includes="xforms|label,xforms|help,xforms|hint,xforms|alert"/>
>                <xforms:trigger xmlns=""
>                                appearance="minimal"
>                                id="">
>                    <xforms:action ev:event="DOMActivate">
>                        <xforms:load ref="fr|hyperlink > xforms|label"
> show="new"/>
>                    </xforms:action>
>                </xforms:trigger>
>            </xforms:group>
>
>        </xbl:template>
>    </xbl:binding>
> </xbl:xbl>
>
> And reference it in the form definition in the heading:
> <xi:include href="oxf:/xbl/rpm/hyperlink/hyperlink.xbl"
> xxi:omit-xml-base="true"/>
>
> When I add my component to the form definition in Form Builder:
>
>                                <fr:hyperlink id="control-2-control"
> bind="control-2-bind">
>                                    <xforms:label
> ref="$form-resources/control-2/label"/>
>                                    <xforms:hint
> ref="$form-resources/control-2/hint"/>
>                                    <xforms:help
> ref="$form-resources/control-2/help"/>
>                                    <xforms:alert
> ref="$fr-resources/detail/labels/alert"/>
>                                </fr:hyperlink>
>
> And test run it, I get the following error:
> Duplicate id found for effective id: control-2-control$xf-454
>
> I'm not to sure where it comes from, what is it refering too?
>
> Thanks in advance.
>
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Custom-XBL-component-tp4196663p4196663.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> 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
>


--
Grégoire Neuville


--
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
Reply | Threaded
Open this post in threaded view
|

Re: Custom XBL component

marek2608
Yes it helps thanks alot.

I am new to XBL and XForms in general so I am missing lots of subtilties at this point.

I manage to rewrite the XBL as follows:

<xbl:xbl xmlns:xhtml="http://www.w3.org/1999/xhtml"
         xmlns:xforms="http://www.w3.org/2002/xforms"
         xmlns:xs="http://www.w3.org/2001/XMLSchema"
         xmlns:ev="http://www.w3.org/2001/xml-events"
         xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
         xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
         xmlns:xbl="http://www.w3.org/ns/xbl"
         xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         xmlns:oxf="http://www.orbeon.com/oxf/processors"
         xmlns:exf="http://www.exforms.org/exf/1-0" >
         

    <xbl:binding element="fr|hyperlink">
        <xbl:template >
            <xforms:group xbl:attr="model context ref bind" xxbl:scope="outer">
                <xbl:content includes="xforms|label,xforms|help,xforms|hint,xforms|alert"/>
                <xforms:group appearance="xxforms:internal" xxbl:scope="inner"> 
                     <xxforms:variable name="binding"> 
                         <xxforms:sequence select="." xxbl:scope="outer" /> 
                     </xxforms:variable> 
                     <xxforms:variable name="label" value="????"/>
                        <xforms:trigger ref="$binding" appearance="minimal" >
                            <xforms:label ref="$label"/>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:load ref="$label" show="new"/>
                            </xforms:action>
                        </xforms:trigger>
            </xforms:group>
          </xforms:group>
        </xbl:template>
    </xbl:binding>
</xbl:xbl>

My next question is: how can I set the label variable so it contains the value of the label provided by the user in the Form Builder, in the form's instance resources:
            <xforms:instance id="fr-form-resources" xxforms:readonly="false">
                <resources>
                    <resource xml:lang="en">
                        <control-1>
                            <label>http://www.google.com</label>
                            <hint/>
                            <help/>
                            <alert/>
                        </control-1>

My guess is using the binding element, but I'm not too sure how this would be expressed.

Thanks again
Reply | Threaded
Open this post in threaded view
|

Re: Re: Custom XBL component

Grégoire Neuville
There is a variable available in outer scope (the scope of you main
xforms document) named fr-resources I think. So in the inner scope of
your component, you could access it this way :

<xxforms:variable name="fr-resources">
  <xxforms:sequence select="$fr-resources" xxbl:scope="outer" />
</xxforms:variable>

On 14 December 2011 21:59, marek2608 <[hidden email]> wrote:

> Yes it helps thanks alot.
>
> I am new to XBL and XForms in general so I am missing lots of subtilties at
> this point.
>
> I manage to rewrite the XBL as follows:
>
> <xbl:xbl xmlns:xhtml="http://www.w3.org/1999/xhtml"
>         xmlns:xforms="http://www.w3.org/2002/xforms"
>         xmlns:xs="http://www.w3.org/2001/XMLSchema"
>         xmlns:ev="http://www.w3.org/2001/xml-events"
>         xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
>         xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
>         xmlns:xbl="http://www.w3.org/ns/xbl"
>         xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
>         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>         xmlns:oxf="http://www.orbeon.com/oxf/processors"
>         xmlns:exf="http://www.exforms.org/exf/1-0" >
>
>
>    <xbl:binding element="fr|hyperlink">
>        <xbl:template >
>            <xforms:group xbl:attr="model context ref bind"
> xxbl:scope="outer">
>                <xbl:content
> includes="xforms|label,xforms|help,xforms|hint,xforms|alert"/>
>                <xforms:group appearance="xxforms:internal"
> xxbl:scope="inner">
>                     <xxforms:variable name="binding">
>                         <xxforms:sequence select="." xxbl:scope="outer" />
>                     </xxforms:variable>
>                     <xxforms:variable name="label" value="????"/>
>                        <xforms:trigger ref="$binding" appearance="minimal" >
>                            <xforms:label ref="$label"/>
>                            <xforms:action ev:event="DOMActivate">
>                                <xforms:load ref="$label" show="new"/>
>                            </xforms:action>
>                        </xforms:trigger>
>            </xforms:group>
>          </xforms:group>
>        </xbl:template>
>    </xbl:binding>
> </xbl:xbl>
>
> My next question is: how can I set the label variable so it contains the
> value of the label provided by the user in the Form Builder, in the form's
> instance resources:
>            <xforms:instance id="fr-form-resources"
> xxforms:readonly="false">
>                <resources>
>                    <resource xml:lang="en">
>                        <control-1>
>                            <label>http://www.google.com</label>
>                            <hint/>
>                            <help/>
>                            <alert/>
>                        </control-1>
>
> My guess is using the binding element, but I'm not too sure how this would
> be expressed.
>
> Thanks again
>
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Custom-XBL-component-tp4196663p4196990.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> 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
>


--
Grégoire Neuville


--
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
Reply | Threaded
Open this post in threaded view
|

Re: Re: Custom XBL component

Grégoire Neuville
And I dont get what you're trying to do with the xforms:load thing...
Probably this :

<xforms:trigger ref="$binding" appearance="minimal" >
  <xforms:label>
    <xforms:output value="$fr-resources/mylabel" />
  </xforms:label>
</xforms:trigger>

no ?

2011/12/14 Grégoire Neuville <[hidden email]>:

> There is a variable available in outer scope (the scope of you main
> xforms document) named fr-resources I think. So in the inner scope of
> your component, you could access it this way :
>
> <xxforms:variable name="fr-resources">
>  <xxforms:sequence select="$fr-resources" xxbl:scope="outer" />
> </xxforms:variable>
>
> On 14 December 2011 21:59, marek2608 <[hidden email]> wrote:
>> Yes it helps thanks alot.
>>
>> I am new to XBL and XForms in general so I am missing lots of subtilties at
>> this point.
>>
>> I manage to rewrite the XBL as follows:
>>
>> <xbl:xbl xmlns:xhtml="http://www.w3.org/1999/xhtml"
>>         xmlns:xforms="http://www.w3.org/2002/xforms"
>>         xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>         xmlns:ev="http://www.w3.org/2001/xml-events"
>>         xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
>>         xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
>>         xmlns:xbl="http://www.w3.org/ns/xbl"
>>         xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
>>         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>         xmlns:oxf="http://www.orbeon.com/oxf/processors"
>>         xmlns:exf="http://www.exforms.org/exf/1-0" >
>>
>>
>>    <xbl:binding element="fr|hyperlink">
>>        <xbl:template >
>>            <xforms:group xbl:attr="model context ref bind"
>> xxbl:scope="outer">
>>                <xbl:content
>> includes="xforms|label,xforms|help,xforms|hint,xforms|alert"/>
>>                <xforms:group appearance="xxforms:internal"
>> xxbl:scope="inner">
>>                     <xxforms:variable name="binding">
>>                         <xxforms:sequence select="." xxbl:scope="outer" />
>>                     </xxforms:variable>
>>                     <xxforms:variable name="label" value="????"/>
>>                        <xforms:trigger ref="$binding" appearance="minimal" >
>>                            <xforms:label ref="$label"/>
>>                            <xforms:action ev:event="DOMActivate">
>>                                <xforms:load ref="$label" show="new"/>
>>                            </xforms:action>
>>                        </xforms:trigger>
>>            </xforms:group>
>>          </xforms:group>
>>        </xbl:template>
>>    </xbl:binding>
>> </xbl:xbl>
>>
>> My next question is: how can I set the label variable so it contains the
>> value of the label provided by the user in the Form Builder, in the form's
>> instance resources:
>>            <xforms:instance id="fr-form-resources"
>> xxforms:readonly="false">
>>                <resources>
>>                    <resource xml:lang="en">
>>                        <control-1>
>>                            <label>http://www.google.com</label>
>>                            <hint/>
>>                            <help/>
>>                            <alert/>
>>                        </control-1>
>>
>> My guess is using the binding element, but I'm not too sure how this would
>> be expressed.
>>
>> Thanks again
>>
>>
>> --
>> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Custom-XBL-component-tp4196663p4196990.html
>> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>>
>>
>> --
>> 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
>>
>
>
>
> --
> Grégoire Neuville


--
Grégoire Neuville


--
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
Reply | Threaded
Open this post in threaded view
|

Re: Re: Custom XBL component

marek2608
Open the URL provided in the label, this part works fine if I get the label value properly...
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Custom XBL component

Grégoire Neuville
Ah, ok. Well, if the url is in $fr-resources, your code should do it,
doesn't it ?

On 14 December 2011 22:12, marek2608 <[hidden email]> wrote:

> Open the URL provided in the label, this part works fine if I get the label
> value properly...
>
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Custom-XBL-component-tp4196663p4197058.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> 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
>


--
Grégoire Neuville


--
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
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Custom XBL component

marek2608
Almost there I guess...
yes I amble to refer to $form-resources variable... from there I should be able to reach my control's label value.

My XBL that seems to work is:

<xbl:xbl xmlns:xhtml="http://www.w3.org/1999/xhtml"
         xmlns:xforms="http://www.w3.org/2002/xforms"
         xmlns:xs="http://www.w3.org/2001/XMLSchema"
         xmlns:ev="http://www.w3.org/2001/xml-events"
         xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
         xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
         xmlns:xbl="http://www.w3.org/ns/xbl"
         xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         xmlns:oxf="http://www.orbeon.com/oxf/processors"
         xmlns:exf="http://www.exforms.org/exf/1-0" >
         

    <xbl:binding element="fr|hyperlink">
        <xbl:template >
            <xforms:group xbl:attr="model context ref bind" xxbl:scope="outer">
                <xbl:content includes="xforms|label,xforms|help,xforms|hint,xforms|alert"/>
                <xforms:group appearance="xxforms:internal" xxbl:scope="inner"> 
                     <xxforms:variable name="binding"> 
                         <xxforms:sequence select="." xxbl:scope="outer" /> 
                     </xxforms:variable> 
                     <xxforms:variable name="form-resources"> 
                         <xxforms:sequence select="$form-resources" xxbl:scope="outer" /> 
      </xxforms:variable> 

                        <xforms:trigger ref="$binding" appearance="minimal" >
                            <xforms:label ref="$form-resources/control-1/label"/>
                            <xforms:action ev:event="DOMActivate">
                                <xforms:load ref="$form-resources/control-1/label" show="new"/>
                            </xforms:action>
                        </xforms:trigger>
            </xforms:group>
          </xforms:group>
        </xbl:template>
    </xbl:binding>
</xbl:xbl>

But it's not fullly dynamic.
Now, my question is concerning the ref: $form-resources/control-1/label

How can I dynamically retrieve the "control-1" name... the control name is provided by the user and set in the bind element.

            <xforms:bind id="fr-form-binds" nodeset="instance('fr-form-instance')">
                <xforms:bind id="section-1-bind" nodeset="section-1">
                    <xforms:bind id="control-1-bind" nodeset="control-1" name="control-1"/>
                   
                </xforms:bind>
            </xforms:bind>

Thanks again and again