PDA

View Full Version : Strange behavior when adding text to listbox


ljk25
10-25-2007, 06:43 AM
Hi there, I'm new to openlaszlo and I've encounter a small issue that troubles me, I'm experimenting with the code from the tutorial as shown below.

<canvas height="300" width="500">
<window x="20" y="20" width="200" height="250"
title="Simple Window" resizable="true">
<simplelayout axis="y" spacing="10"/>
<text>Here is some text.</text>
<text>I could ramble for hours.</text>
<list id="mylist" height="50">
<textlistitem text="something"/>
</list>
<edittext id="item" text="demo" />
<button text="my button">
<handler name="onclick">
mylist.addItem(item.getText());
slist.addItem(item.getText());
</handler>
</button>
</window>
<window width="200" height="250">
<list id="slist" height="100">

</list>
</window>
</canvas>

if I remove the <textlistitem text="something"/> line in the following code, no item will be added to "mylist" and "slist" when I click the button, otherwise, both list will be added with the item "demo".

however, if <textlistitem> must exist inorder that an item can be added to a list, how can "slist" be added even thou <textlistitem> doesn't appear within it? is this a bug or have i made a mistake somewhere? I'm using openlaszlo 4.0.6. thanks in advance.

senshi
10-25-2007, 09:54 AM
Oh, that's just a common "mistake" most beginners are confronted with.

Short explanation:

compiler does not find any <textlistitem> node
therefore compiler won't auto-include the required file ("lz/textlistitem.lzx")
reason: this will reduce the output-file's size
"addItem(..)" will try to create and add a new list-item through scripting
but it'll fail, because the definition of the <textlistitem>-class is missing

result: no items are added



<canvas height="300" width="500" debug="true" >
<include href="lz/textlistitem.lzx" />

[I][...]

</canvas>