Bind in a repeat

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

Bind in a repeat

npujol73
Hi,

 I am pretty sure this is has been answered many times but I could not
find the attached example to work.

I have a repeat section that includes 2 'linked' drop downs
(country/state) and I am trying to 'hide' (using relevant) the state
when the
country is something other than US. I cannot get it to work when I
have multiple items. I've tried multiple things (using index() etc...
but no luck).

Thanks for any tips you may have

Here is a summarized version (see the attached for the full version)

       <xforms:instance id="data">
                <root xmlns="">
                    <item>
                        <country/>
                        <state/>
                    </item>
                </root>
            </xforms:instance>
            <xforms:instance id="ui">
                <countries xmlns="">
                    <country cd="0" desc="UNITED STATES">
                        <state cd="AL" desc="Alabama"/>
                        <state cd="AK" desc="Alaska"/>
                    </country>
                    <country cd="1" desc="OTHER"/>
                </countries>
            </xforms:instance>

 <xforms:bind nodeset="instance('data')/item">
                <xforms:bind nodeset="state" relevant="country='0'"/>
            </xforms:bind>

 <xforms:repeat id="idx" nodeset="instance('data')/item">
                <xxforms:variable name="info-position" select="position()"/>
                <tr>
                    <td>
                        <xforms:select1 ref="country">
                            <xforms:label> Country </xforms:label>
                            <xforms:item>
                                <xforms:label/>
                                <xforms:value/>
                            </xforms:item>
                            <xforms:itemset nodeset="instance('ui')/country">
                                <xforms:label ref="@desc"/>
                                <xforms:value ref="@cd"/>
                            </xforms:itemset>
                        </xforms:select1>
                    </td>
                    <td>
                        <xforms:select1 ref="state">
                            <xforms:label>State</xforms:label>
                            <xforms:item>
                                <xforms:label/>
                                <xforms:value/>
                            </xforms:item>
                            <xforms:itemset
nodeset="instance('ui')/country[@cd=instance('data')/item[$info-position]/country]/state">
                                <xforms:label ref="@desc"/>
                                <xforms:value ref="@cd"/>
                            </xforms:itemset>
                        </xforms:select1>
                    </td>
                </tr>
            </xforms:repeat>


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

simpleForm2.xhtml (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Bind in a repeat

                                                                    </xforms:repeat>

 

--
You receive this message as a subscriber of the ops-users@ow2.org mailing list.
To unsubscribe: mailto:ops-users-unsubscribe@ow2.org
For general help: mailto:sympa@ow2.org?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
npujol73
Ok I figured it out myself. Very simple but through me in a loop ;) Here is the appropriate bind:


 <xforms:bind nodeset="instance('data')/item/state" relevant="../country='0'"/>

May save someone a few hrs.

npujol73 wrote
Hi,

 I am pretty sure this is has been answered many times but I could not
find the attached example to work.

I have a repeat section that includes 2 'linked' drop downs
(country/state) and I am trying to 'hide' (using relevant) the state
when the
country is something other than US. I cannot get it to work when I
have multiple items. I've tried multiple things (using index() etc...
but no luck).

Thanks for any tips you may have

Here is a summarized version (see the attached for the full version)

       <xforms:instance id="data">
                <root xmlns="">
                    <item>
                        <country/>
                        <state/>
                    </item>
                </root>
            </xforms:instance>
            <xforms:instance id="ui">
                <countries xmlns="">
                    <country cd="0" desc="UNITED STATES">
                        <state cd="AL" desc="Alabama"/>
                        <state cd="AK" desc="Alaska"/>
                    </country>
                    <country cd="1" desc="OTHER"/>
                </countries>
            </xforms:instance>

 <xforms:bind nodeset="instance('data')/item">
                <xforms:bind nodeset="state" relevant="country='0'"/>
            </xforms:bind>

 <xforms:repeat id="idx" nodeset="instance('data')/item">
                <xxforms:variable name="info-position" select="position()"/>
               
                        <xforms:select1 ref="country">
                            <xforms:label> Country </xforms:label>
                            <xforms:item>
                                <xforms:label/>
                                <xforms:value/>
                            </xforms:item>
                            <xforms:itemset nodeset="instance('ui')/country">
                                <xforms:label ref="@desc"/>
                                <xforms:value ref="@cd"/>
                            </xforms:itemset>
                        </xforms:select1>
                   
                        <xforms:select1 ref="state">
                            <xforms:label>State</xforms:label>
                            <xforms:item>
                                <xforms:label/>
                                <xforms:value/>
                            </xforms:item>
                            <xforms:itemset
nodeset="instance('ui')/country[@cd=instance('data')/item[$info-position]/country]/state">
                                <xforms:label ref="@desc"/>
                                <xforms:value ref="@cd"/>
                            </xforms:itemset>
                        </xforms:select1>