Topic
  • 5 replies
  • Latest Post - ‏2011-03-07T06:19:44Z by SystemAdmin
Augo
Augo
3 Posts

Pinned topic selecting items in a list

‏2011-03-05T03:50:48Z |
Assume I have a list of items. For the sake of the example, we'll say different types of flowers. I send that list of items from the server to the xform and display them using a repeater. Now, the person using the xform has the option of selecting/deselecting any and each item in the list. They might, for example, select tulips and roses and deselect daffodils and tiger lillies. I want to capture the items they selected/deselected and send it back to the server. In addition, certain items may have other decision points to be made as well (for example, does the user want 6 roses in a crystal vase or 12 roses in an economy vase?)
To keep the amount of data moving between the server and the xform to a minimum, I only want what absolutely must be sent whenever data is moved from the server to the client (or vice versa).

I have been staring at the Wikibooks site on XForms for about two weeks now trying to figure out how to solve this particular problem and I'm about ready to throw in the towel. I just can't figure out how to do it. If anybody can give a noob a hand, I'd be very grateful.
Updated on 2011-03-07T06:19:44Z at 2011-03-07T06:19:44Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    265 Posts

    Re: selecting items in a list

    ‏2011-03-05T18:37:47Z  
    Augo,

    We can't help you much with this type of general questions here. If the examples in the WikiBooks don't help, I recommend going through this XForms tutorial, which takes you through the steps of creating a form from A to Z, including how to persist the data. Then if you have specific problems (I try to do A by doing B, instead instead get result C), feel free to post here and we'll then be more likely to be able to help you.

    Alex
    --
    Orbeon Forms - Web 2.0 Forms, open source, for the Enterprise
    http://www.orbeon.com/
  • Augo
    Augo
    3 Posts

    Re: selecting items in a list

    ‏2011-03-06T02:37:46Z  
    Augo,

    We can't help you much with this type of general questions here. If the examples in the WikiBooks don't help, I recommend going through this XForms tutorial, which takes you through the steps of creating a form from A to Z, including how to persist the data. Then if you have specific problems (I try to do A by doing B, instead instead get result C), feel free to post here and we'll then be more likely to be able to help you.

    Alex
    --
    Orbeon Forms - Web 2.0 Forms, open source, for the Enterprise
    http://www.orbeon.com/
    Thanks,

    I suspect there are multiple issues going on here. I'll try to break it down into one problem at a time and show code snippets as needed.

    So, first problem.
    Here's my code
    <?xml version="1.0" encoding="iso-8859-1"?>
    <?xsltforms-options debug="yes"?>
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:inv="http://www.bobsflowers.org/2011/spring" xmlns:biz="http:www.bobsflowers.org/2011/purchases">
    <head>
    <title>Phone List</title>
    <xf:model>
    <xf:instance xmlns="http:www.bobsflowers.org/2011/purchases" id="purchaseorder">
    <purchase_order>
    <order>
    <item><skew></skew><delivery_location></delivery_location></item>
    </order>
    </purchase_order>
    </xf:instance>
    <xf:instance xmlns="http://www.bobsflowers.org/2011/spring" id="supplies">
    <inventory>
    <items>
    <item skew="fl1001"><name>tulips</name></item>
    <item skew="fl1002"><name>roses</name>></item>
    <item skew="fl1003"><name>daffodils</name></item>
    </items>
    </inventory>
    </xf:instance>
    </xf:model>
    <xf:bind id="include" nodeset="include" type="xs:boolean"/>
    </head>
    <body>
    <fieldset>
    <legend>Purchase List</legend>

    skew, item
    <xf:repeat nodeset="instance('supplies')/inv:items/inv:item">
    <xf:input bind="include"/>
    <xf:output ref="@skew"/>,
    <xf:output ref="inv:name"/>

    <xf:textarea ref="instance('purchaseorder')/biz:order/biz:delivery_location">
    <xf:label>Delivery Location:</xf:label>
    </xf:textarea>
    </xf:repeat>

    </fieldset>
    </body>
    </html>

    The "include" input should be a checkbox, but is showing up as a textbox and the textarea isn't showing up at all.
    This is in the Firefox XForms plug-in.
  • SystemAdmin
    SystemAdmin
    265 Posts

    Re: selecting items in a list

    ‏2011-03-06T07:57:38Z  
    • Augo
    • ‏2011-03-06T02:37:46Z
    Thanks,

    I suspect there are multiple issues going on here. I'll try to break it down into one problem at a time and show code snippets as needed.

    So, first problem.
    Here's my code
    <?xml version="1.0" encoding="iso-8859-1"?>
    <?xsltforms-options debug="yes"?>
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:inv="http://www.bobsflowers.org/2011/spring" xmlns:biz="http:www.bobsflowers.org/2011/purchases">
    <head>
    <title>Phone List</title>
    <xf:model>
    <xf:instance xmlns="http:www.bobsflowers.org/2011/purchases" id="purchaseorder">
    <purchase_order>
    <order>
    <item><skew></skew><delivery_location></delivery_location></item>
    </order>
    </purchase_order>
    </xf:instance>
    <xf:instance xmlns="http://www.bobsflowers.org/2011/spring" id="supplies">
    <inventory>
    <items>
    <item skew="fl1001"><name>tulips</name></item>
    <item skew="fl1002"><name>roses</name>></item>
    <item skew="fl1003"><name>daffodils</name></item>
    </items>
    </inventory>
    </xf:instance>
    </xf:model>
    <xf:bind id="include" nodeset="include" type="xs:boolean"/>
    </head>
    <body>
    <fieldset>
    <legend>Purchase List</legend>

    skew, item
    <xf:repeat nodeset="instance('supplies')/inv:items/inv:item">
    <xf:input bind="include"/>
    <xf:output ref="@skew"/>,
    <xf:output ref="inv:name"/>

    <xf:textarea ref="instance('purchaseorder')/biz:order/biz:delivery_location">
    <xf:label>Delivery Location:</xf:label>
    </xf:textarea>
    </xf:repeat>

    </fieldset>
    </body>
    </html>

    The "include" input should be a checkbox, but is showing up as a textbox and the textarea isn't showing up at all.
    This is in the Firefox XForms plug-in.
    Yes, multiple issues indeed ;-)

    I think I fixed them all with both Mozilla XForms Extension and XSLTForms:

    
    <?xml version=
    "1.0" encoding=
    "iso-8859-1"?> <html xmlns=
    "http://www.w3.org/1999/xhtml" xmlns:xsd=
    "http://www.w3.org/2001/XMLSchema" xsd:dummy=
    "dummy" xmlns:xf=
    "http://www.w3.org/2002/xforms" xmlns:inv=
    "http://www.bobsflowers.org/2011/spring" xmlns:biz=
    "http:www.bobsflowers.org/2011/purchases" inv:dummy=
    "dummy" biz:dummy=
    "dummy"> <head> <title>Phone List</title> <xf:model> <xf:instance xmlns=
    "http:www.bobsflowers.org/2011/purchases" id=
    "purchaseorder"> <purchase_order> <order> <item><skew></skew><delivery_location></delivery_location></item> </order> </purchase_order> </xf:instance> <xf:instance xmlns=
    "http://www.bobsflowers.org/2011/spring" id=
    "supplies"> <inventory> <items> <item skew=
    "fl1001"><name>tulips</name><include>true</include></item> <item skew=
    "fl1002"><name>roses</name>><include>false</include></item> <item skew=
    "fl1003"><name>daffodils</name><include>true</include></item> </items> </inventory> </xf:instance> <xf:bind nodeset=
    "instance('supplies')/inv:items/inv:item/inv:include" type=
    "xsd:boolean"/> </xf:model> </head> <body> <fieldset> <legend>Purchase List</legend>   skew, item <xf:repeat nodeset=
    "instance('supplies')/inv:items/inv:item"> <xf:input ref=
    "inv:include"/> <xf:output ref=
    "@skew"/>, <xf:output ref=
    "inv:name"/>   <xf:textarea ref=
    "instance('purchaseorder')/biz:order/biz:item/biz:delivery_location"> <xf:label>Delivery Location:</xf:label> </xf:textarea> </xf:repeat> </fieldset> </body> </html>
    

    Do you have questions about this?

    -Alain
  • Augo
    Augo
    3 Posts

    Re: selecting items in a list

    ‏2011-03-06T18:07:51Z  
    Yes, multiple issues indeed ;-)

    I think I fixed them all with both Mozilla XForms Extension and XSLTForms:

    <pre class="jive-pre"> <?xml version= "1.0" encoding= "iso-8859-1"?> <html xmlns= "http://www.w3.org/1999/xhtml" xmlns:xsd= "http://www.w3.org/2001/XMLSchema" xsd:dummy= "dummy" xmlns:xf= "http://www.w3.org/2002/xforms" xmlns:inv= "http://www.bobsflowers.org/2011/spring" xmlns:biz= "http:www.bobsflowers.org/2011/purchases" inv:dummy= "dummy" biz:dummy= "dummy"> <head> <title>Phone List</title> <xf:model> <xf:instance xmlns= "http:www.bobsflowers.org/2011/purchases" id= "purchaseorder"> <purchase_order> <order> <item><skew></skew><delivery_location></delivery_location></item> </order> </purchase_order> </xf:instance> <xf:instance xmlns= "http://www.bobsflowers.org/2011/spring" id= "supplies"> <inventory> <items> <item skew= "fl1001"><name>tulips</name><include>true</include></item> <item skew= "fl1002"><name>roses</name>><include>false</include></item> <item skew= "fl1003"><name>daffodils</name><include>true</include></item> </items> </inventory> </xf:instance> <xf:bind nodeset= "instance('supplies')/inv:items/inv:item/inv:include" type= "xsd:boolean"/> </xf:model> </head> <body> <fieldset> <legend>Purchase List</legend> skew, item <xf:repeat nodeset= "instance('supplies')/inv:items/inv:item"> <xf:input ref= "inv:include"/> <xf:output ref= "@skew"/>, <xf:output ref= "inv:name"/> <xf:textarea ref= "instance('purchaseorder')/biz:order/biz:item/biz:delivery_location"> <xf:label>Delivery Location:</xf:label> </xf:textarea> </xf:repeat> </fieldset> </body> </html> </pre>
    Do you have questions about this?

    -Alain
    THANK YOU!

    I was trying to do it without having the <include/> node in the inventory, but I see how what you did is much more elegant. It's not too bad of a hit to include all of those empty nodes when downloading the inventory to the website.

    So, next question. How do I associate the proper skew number to the proper purchaseorder item?
  • SystemAdmin
    SystemAdmin
    265 Posts

    Re: selecting items in a list

    ‏2011-03-07T06:19:44Z  
    • Augo
    • ‏2011-03-06T18:07:51Z
    THANK YOU!

    I was trying to do it without having the <include/> node in the inventory, but I see how what you did is much more elegant. It's not too bad of a hit to include all of those empty nodes when downloading the inventory to the website.

    So, next question. How do I associate the proper skew number to the proper purchaseorder item?
    Augo,

    Are you saying that you don't want an <include> element in the supplies instance because you'd like that instance to be read-only (just containing information about flowers available, separate from those selected)? If that is the case, instead of using a checkbox, would it work for you to use a button or link "add to order" that would add one line to the purchase order when clicked on?

    Alex
    --
    Orbeon Forms - Web 2.0 Forms, open source, for the Enterprise
    http://www.orbeon.com/