Dynamic Lookups on a repeating Instance

View: New views
1 Messages — Rating Filter:   Alert me  

Dynamic Lookups on a repeating Instance

by Chris Grocott :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is this a bug ?

When I select as value from a dynamic lookup (SELECT1) and then move to the next repeat of the instance, the SELECT1’s in all repeats of the instance re-size which is annoying. What is more of a problem is that the value I have just selected in the REPEAT I have just left disappears from the screen – despite being present and correct in the instance (proved by displaying it as output on the screen and viewing it through Mozilla Forms Buddy).

To explain this I have borrowed the wikibook example from (“XForms / Dynamic Selection Lists” ) and amended it, firstly to use nodes rather than elements, and secondly to work on a REPEAT rather than a single occurrence instance. This XHTML code is a simple example:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xf="http://www.w3.org/2002/xforms">
    <head>
        <title>Test conditional Selection Lists / Dynamic Lookups</title>
        <xf:model id="data_model">
            <xf:instance xmlns="" id="data">
                <dataset>
                    <data>
                        <selected-season>winter</selected-season>

                        <selected-month/>
                    </data>
                    <data>
                        <selected-season>spring</selected-season>
                        <selected-month/>
                    </data>
                    <data>
                        <selected-season>summer</selected-season>

                        <selected-month/>
                    </data>
                    <data>
                        <selected-season>autumn</selected-season>
                        <selected-month/>
                    </data>
                </dataset>
            </xf:instance>

            <xf:instance xmlns="" id="seasons">
                <root>
                    <item>winter</item>
                    <item>spring</item>
                    <item>summer</item>
                    <item>autumn</item>
                </root>

            </xf:instance>
            <xf:instance xmlns="" id="months">
                <root>
                    <item1>
                        <name>January</name>
                        <season>winter</season>
                    </item1>
                    <item1>

                        <name>February</name>
                        <season>winter</season>
                    </item1>
                    <item1>
                        <name>March</name>
                        <season>spring</season>
                    </item1>

                    <item1>
                        <name>April</name>
                        <season>spring</season>
                    </item1>
                    <item1>
                        <name>May</name>
                        <season>spring</season>

                    </item1>
                    <item1>
                        <name>June</name>
                        <season>summer</season>
                    </item1>
                    <item1>
                        <name>July</name>

                        <season>summer</season>
                    </item1>
                    <item1>
                        <name>August</name>
                        <season>summer</season>
                    </item1>
                    <item1>

                        <name>September</name>
                        <season>autumn</season>
                    </item1>
                    <item1>
                        <name>October</name>
                        <season>autumn</season>
                    </item1>

                    <item1>
                        <name>November</name>
                        <season>autumn</season>
                    </item1>
                    <item1>
                        <name>December</name>
                        <season>winter</season>

                    </item1>
                </root>
            </xf:instance>
        </xf:model>
    </head>
    <body>
        <h4>Test conditional Selection Lists / Dynamic Lookups - month selector depends on the current season</h4>
        <p>NOTE 1: This version was amended form the Wikibook example to use nodes rather than attributes and to work with a REPEAT</p>

        <p>NOTE 2: Once the month is selected from the Season restricted SELECT1, after the selection when you move to the next REPEAT, it doesn't always display </p>
        <p>in its SELECT1. However, it  is present in the output on the screen and also in the instance (when viewed through Mozilla Forms Buddy)</p>
        <table>
            <xf:repeat model="data_model" id="data_repeat" nodeset="/dataset/data">
                <tr>
                    <td>
                        <xf:select1 ref="selected-season">
                            <xf:label>Season:</xf:label>

                            <xf:itemset nodeset="instance('seasons')/item">
                                <xf:label ref="."/>
                                <xf:value ref="."/>
                            </xf:itemset>
                        </xf:select1>
                    </td>
                    <td>
                        <xf:select1 ref="selected-month">
                            <xf:label>Month:</xf:label>

                            <xf:itemset nodeset="instance('months')/item1[season=instance('data')/data[index('data_repeat')]/selected-season]">
                                <xf:label ref="name"/>
                                <xf:value ref="name"/>
                            </xf:itemset>
                        </xf:select1>
                    </td>
                    <td>
                        <xf:output ref="selected-season">
                            <xf:label>Selected Season: </xf:label>
                        </xf:output>
                        <xf:output ref="selected-month">
                            <xf:label>Selected Month: </xf:label>
                        </xf:output>
                    </td>
                </tr>
            </xf:repeat>
        </table>
    </body>
</html>



I also get the same results in my larger .XQL dynamic XForm.

Is this a bug and does anybody have any suggestion as to why the value disappears from the screen ?

Chris
LightInTheBox - Buy quality products at wholesale price