PDA

View Full Version : binding form elements to dataset


bernardsirius
10-07-2004, 04:17 AM
Is it possible to bind the value displayed by form elements to dataset values using e.g. xpath ?

For example, say I have a dynamically generated list of dishes I want my users to choose from, can I define a dataset pointing to some jsp or whatever, and populate a Combobox with the provided values?

Mishre
10-07-2004, 04:32 AM
I don't know a direct answer to your question, given that I have never worked with Laszlo yet. However you may be able to use JavaScript to call the server when the field needs to be updated.

I'm thinking XML-RPC, or a script that returns the properly formatted data. You would need to determine whatn the list should be updated and what will trigger that update.

jsundman
10-07-2004, 09:06 AM
Have you worked through the documentation? I suggest starting here:

http://www.laszlosystems.com/lps-2.2/docs/guide/data-tutorial.html

antun
10-07-2004, 10:30 AM
Sure - you can also select an item in the combobox based on some arbitrary value provided by the data:


<canvas>
<dataset name="items">
<items select="3">
<item value="item1">item one</item>
<item value="item2">item two</item>
<item value="item3">item three</item>
<item value="item4">item four</item>
</items>
</dataset>

<class name="mycombo" extends="combobox"
width="130"
shownitems="3"
defaulttext="choose one..." >
<method name="applyData" args="d">
this.itemToSelect = parseInt(d); // 1 based
</method>
<method event="oninit" reference="canvas">
var i = this.itemToSelect - 1; // 0 based
this.selectItemAt( i );
</method>
</class>

<mycombo x="5" y="5" datapath="items:/items[1]/@select" name="myc">
<textlistitem datapath="items:/items[1]/item" text="$path{'text()'}"
value="$path{'@value'}"/>
</mycombo>
</canvas>


Originally posted by bernardsirius
For example, say I have a dynamically generated list of dishes I want my users to choose from, can I define a dataset pointing to some jsp or whatever, and populate a Combobox with the provided values?