Variables in xbl:Databound-select1

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

Variables in xbl:Databound-select1

PatrickJ
Hi,

I would like to use the databound-select1 xbl component to create dependencies between multiple picklists.
Examples on how to use the databound-select1 are pretty clear but my challenge goes beyond it:

I need to build an XForms page out of an XML (with prefixes) that gets rendered through XSLT.
XML is telling me how many picklists to build and which depends on which. The same full XML is then used as the XForns instance and the elements that tell me how to build a picklist need to be updated with the selected value from that picklist.

Underneath a (simplified) part of the XForms instance as an example:

	<pre:Element Datatype="picklist" Label="Label A" dependsOn="">
		<pre:ElementName>ListA1</pre:ElementName>
		<pre:SelectedElementValue/>
		<pre:ListOElementVal>
			<pre:ElementVal>
				<pre:ElementValue>Choice A1</pre:ElementValue>
				<pre:ElementId>idA1</pre:ElementId>
			</pre:ElementVal>
			<pre:ElementVal>
				<pre:ElementValue>Choice A2</pre:ElementValue>
				<pre:ElementId>idA2</pre:ElementId>
			</pre:ElementVal>
		</pre:ListOElementVal>
	</pre:Element>
	<pre:Element Datatype="picklist" Label="Label B" dependsOn="ListA1">
		<pre:ElementName>ListB1</pre:ElementName>
		<pre:SelectedElementValue/>
		<pre:SelectedElementId/>
		<pre:ListOElementVal/>
	</pre:Element>

So this builds 2 picklists, ListA1 and ListB1 where element <pre:SelectedElementValue/> will be used as the ref for the selected value and the items of ListB1 will be draw from a resource that takes ListA1's <pre:SelectedElementValue/> as a parameter.
For my databound-select1 this will have to look something like this (again this has been simplified):

            <fr:databound-select1 ref="pre:Element[@Datatype='picklist'][pre:ElementName='ListA1']/pre:SelectedElementValue" appearance="minimal"
                                   resource="/getResources?param='firstlist'">
                <xforms:label>List B: </xforms:label>
                <xforms:itemset nodeset="/items">
                    <xforms:label ref="@label"/>
                    <xforms:value ref="@value"/>
                </xforms:itemset>
            </fr:databound-select1>

            <fr:databound-select1 ref="pre:Element[@Datatype='picklist'][pre:ElementName='ListB1']/pre:SelectedElementValue" appearance="minimal"
                                   resource="/getResources?param={pre:Element[@Datatype='picklist'][pre:ElementName='ListA1']/pre:SelectedElementValue}">
                <xforms:label>List B: </xforms:label>
                <xforms:itemset nodeset="/items">
                    <xforms:label ref="@label"/>
                    <xforms:value ref="@value"/>
                </xforms:itemset>
            </fr:databound-select1>

Written out this may seem clear but as I stated the page gets rendered through XSLT and so all refs and params will have to be replaced by variables eventually.
I am aware that the AVT in the param does not take prefixes in the XPath so the above code will not work.
I have therefore tried storing the SelectedElementValue in another instance without prefixes by using xform:action but it appears the databound-select1 disables events so the action will not work either.

Is there an easy way to solve my problem?
Reply | Threaded
Open this post in threaded view
|

Re: Variables in xbl:Databound-select1

Erik Bruchez
Administrator
"I am aware that the AVT in the param does not take prefixes in the
XPath". I am not sure I understand this part: the AVT expression will
use the namespace in scopes. So if your XSLT produces XForms with the
proper namespaces scoped at that point, things will work.

This said, a common way to ignore namespaces is to use '*' as prefix,
for example:

resource="/getResources?param={*:Element[@Datatype='picklist'][*:ElementName='ListA1']/*:SelectedElementValue}"

If your don't have elements with the same local name but a different
namespace, things will work.

-Erik

On Tue, Nov 29, 2011 at 2:34 PM, PatrickJ <[hidden email]> wrote:

> Hi,
>
> I would like to use the databound-select1 xbl component to create
> dependencies between multiple picklists.
> Examples on how to use the databound-select1 are pretty clear but my
> challenge goes beyond it:
>
> I need to build an XForms page out of an XML (with prefixes) that gets
> rendered through XSLT.
> XML is telling me how many picklists to build and which depends on which.
> The same full XML is then used as the XForns instance and the elements that
> tell me how to build a picklist need to be updated with the selected value
> from that picklist.
>
> Underneath a (simplified) part of the XForms instance as an example:
>
>
>
> So this builds 2 picklists, ListA1 and ListB1 where element
> <pre:SelectedElementValue/> will be used as the ref for the selected value
> and the items of ListB1 will be draw from a resource that takes ListA1's
> <pre:SelectedElementValue/> as a parameter.
> For my databound-select1 this will have to look something like this (again
> this has been simplified):
>
>
>
> Written out this may seem clear but as I stated the page gets rendered
> through XSLT and so all refs and params will have to be replaced by
> variables eventually.
> I am aware that the AVT in the param does not take prefixes in the XPath so
> the above code will not work.
> I have therefore tried storing the SelectedElementValue in another instance
> without prefixes by using xform:action but it appears the databound-select1
> disables events so the action will not work either.
>
> Is there an easy way to solve my problem?
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Variables-in-xbl-Databound-select1-tp4121043p4121043.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
>


--
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: Variables in xbl:Databound-select1

PatrickJ
Thank you Erik!

The prefix wildcard seems to do most of the trick.

Would you know the reason why the databound-select1 disables all events? And will it harm if I turn them on again?
As of now it does not offer the same functionality as a normail select1.

Cheers,
Patrick
Reply | Threaded
Open this post in threaded view
|

Re: Re: Variables in xbl:Databound-select1

Erik Bruchez
Administrator
Patrick,

Do you mean with this:

<xforms:action ev:event="#all" ev:propagate="stop"/>

The idea is that XBL components should fully encapsulate events.
Unfortunately as of 3.9 (and up until now), this encapsulation is not
fully implemented. This means that some events incorrectly go through
the boundary of XBL components. So with this we stop most undesired
events.

-Erik

On Wed, Nov 30, 2011 at 11:29 PM, PatrickJ <[hidden email]> wrote:

> Thank you Erik!
>
> The prefix wildcard seems to do most of the trick.
>
> Would you know the reason why the databound-select1 disables all events? And
> will it harm if I turn them on again?
> As of now it does not offer the same functionality as a normail select1.
>
> Cheers,
> Patrick
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Variables-in-xbl-Databound-select1-tp4121043p4127331.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
>


--
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