Dynamic data dropdown without web service (filtering static data)

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

Dynamic data dropdown without web service (filtering static data)

juriver
Hi!

I'm trying to do same that described here:

https://doc.orbeon.com/form-runner/component/dynamic-data-dropdown.html

but using static data list from instances inside the form.

I've tried this:

<xf:model>
    ...
    <xf:instance xxf:readonly="true" id="fr-form-resources" xxf:exclude-result-prefixes="#all">
        <resources>
            <resource xml:lang="en">
                <state>
                    <label>StateList</label>
                    <hint/>
                    <item>
                        <label>state1</label>
                        <value>state1</value>
                    </item>
                    <item>
                        <label>state2</label>
                        <value>state2</value>
                    </item>
                </state>
                <city>
                    <label>CityList</label>
                    <hint/>
                    <item>
                        <label>city1_of_state1</label>
                        <value>city1_of_state1</value>
                         <state>state1</state>
                    </item>
                    <item>
                        <label>city2_of_state1</label>
                        <value>value1level1_2</value>
                        <state>state1</state>
                    </item>
                    <item>
                        <label>city1_of_state2</label>
                        <value>city1_of_state2</value>
                        <state>state2</state>
                    </item>
                    <item>
                        <label>city2_of_state2</label>
                        <value>city2_of_state2</value>
                        <state>state2</state>
                    </item>                         
                </city>
                <section-1>
                    <label>Untitled Section</label>
                </section-1>
                      
            </resource>
        </resources>
     </xf:instance>
 </xf:model>
...
<xh:body>
...
    <xf:select1 id="state-control" bind="state-bind" appearance="dropdown">
        <xf:label ref="$form-resources/state/label"/>
        <xf:hint ref="$form-resources/state/hint"/>
        <xf:alert ref="$fr-resources/detail/labels/alert"/>
       
        <xf:itemset ref="$form-resources/state/item">
            <xf:label ref="label"/>
            <xf:value ref="value"/>
        </xf:itemset>
    </xf:select1>
...

    <xf:select1 id="city-control" bind="city-bind" appearance="dropdown">
        <xf:label ref="$form-resources/city/label"/>
        <xf:hint ref="$form-resources/city/hint"/>
        <xf:alert ref="$fr-resources/detail/labels/alert"/>
      
        <xf:itemset ref="$form-resources/city/item[state=$state]">
            <xf:label ref="label"/>
            <xf:value ref="value"/>
        </xf:itemset>
    </xf:select1>
...
</xh:body>



However it doesn't work.

But if I write:

<xf:itemset ref="$form-resources/city/item[state='state2']">

in city-control, it shows cities of state2 (city1_of_state2, city2_of_state2)

What is wrong in my code?

Thanks in advance.
 

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic data dropdown without web service (filtering static data)

Alessandro  Vernet
Administrator
Hi,

In the view, you can't access the value of another control with a variable;
you can only do so in `<xf:bind>` in the model. So in your case, try
replacing `$state` by `xxf:binding('state-control')`. You can also try
adding an `<xf:output value="xxf:binding('state-control')"/>` before you
`<xf:select1>` to check your XPath expressions returns the value you expect.
You'll let us know if this helps,

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic data dropdown without web service (filtering static data)

juriver
Hi.

Yes! It works!:

Writting this:

<xf:itemset ref="$form-resources/city/item[state=xxf:binding('state-control')]">

it works like a charm.

Thanks Alex!!

El martes, 5 de septiembre de 2017, 23:08:31 (UTC+2), Alessandro Vernet escribió:
Hi,

In the view, you can't access the value of another control with a variable;
you can only do so in `<xf:bind>` in the model. So in your case, try
replacing `$state` by `xxf:binding('state-control')`. You can also try
adding an `<xf:output value="xxf:binding('state-control')"/>` before you
`<xf:select1>` to check your XPath expressions returns the value you expect.
You'll let us know if this helps,

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: <a href="http://discuss.orbeon.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdiscuss.orbeon.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF5V5zfD-87RVoalaG4cqO_RzdDcA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdiscuss.orbeon.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF5V5zfD-87RVoalaG4cqO_RzdDcA&#39;;return true;">http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic data dropdown without web service (filtering static data)

Alessandro  Vernet
Administrator
Perfect, and thanks for the confirmation. Always glad seeing things working :).

Alex

On Tue, Sep 5, 2017 at 2:24 PM juriver <[hidden email]> wrote:
Hi.

Yes! It works!:

Writting this:

<xf:itemset ref="$form-resources/city/item[state=xxf:binding('state-control')]">

it works like a charm.

Thanks Alex!!

El martes, 5 de septiembre de 2017, 23:08:31 (UTC+2), Alessandro Vernet escribió:
Hi,

In the view, you can't access the value of another control with a variable;
you can only do so in `<xf:bind>` in the model. So in your case, try
replacing `$state` by `xxf:binding('state-control')`. You can also try
adding an `<xf:output value="xxf:binding('state-control')"/>` before you
`<xf:select1>` to check your XPath expressions returns the value you expect.
You'll let us know if this helps,

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet