PDA

View Full Version : inheritance question: how to put a form item to a spezial position of an inherit form


claudette
03-27-2008, 12:20 PM
I'm a newbie! maybe my question ist stupid, but I have no idea if it is possible or not and how it might be possible.
I have a form (in my code: myForm). and I want to inherit another form from this form (in my code: mysecondform).
this second form should additionally have another form item, for example a checkbox.
I would like to define where to put this checkbox. For example after my radiogroup from my parent form class.
how can I realize it?

a second question:
How can I get data from server for example to fill my list with values?!?
:confused:
are there any tutorials which describe both problems?

thanks in advance!!


<canvas bgcolor="0xeaeaea" width="640" height="1000" debug="true">
<simplelayout spacing="5"/>

<class name="myForm">
<form id="ex1" name="myForm">
<submit name="submitter"/>

<statictext>What is your definition of fun?</statictext>
<radiogroup x="30" name="definition">
<radiobutton value="1">Playing video games</radiobutton>
<radiobutton value="2">Chatting with friends</radiobutton>
<radiobutton value="3">Eating french fries</radiobutton>
</radiogroup>

<statictext>Where do you live?</statictext>
<list name="home" x="30" shownitems="4">
<textlistitem selected="true">city</textlistitem>
<textlistitem>town</textlistitem>
<textlistitem>island</textlistitem>
<textlistitem>village</textlistitem>
<textlistitem>cubby hole</textlistitem>
</list>

<checkbox name="email">Please send me email that is fun.</checkbox>

<button isdefault="true" onclick="parent.submitter.submit()">Submit</button>
</form>
</class>

<class name="mysecondform" extends="myForm" bgcolor="red">
<checkbox name="email">another checkbox</checkbox>
</class>

<myForm />
<mysecondform />

</canvas>

rcyeager
03-27-2008, 08:18 PM
One way is to use the placement attribute to control the target view for placement of controls in subclasses:


<canvas bgcolor="0xeaeaea" width="640" height="1000" debug="true">
<simplelayout spacing="5"/>

<class name="myForm">
<form id="ex1" name="myForm">
<submit name="submitter"/>

<statictext>What is your definition of fun?</statictext>
<radiogroup x="30" name="definition">
<radiobutton value="1">Playing video games</radiobutton>
<radiobutton value="2">Chatting with friends</radiobutton>
<radiobutton value="3">Eating french fries</radiobutton>
</radiogroup>

<view name="checkboxPlace"/>

<statictext>Where do you live?</statictext>
<list name="home" x="30" shownitems="4">
<textlistitem selected="true">city</textlistitem>
<textlistitem>town</textlistitem>
<textlistitem>island</textlistitem>
<textlistitem>village</textlistitem>
<textlistitem>cubby hole</textlistitem>
</list>

<checkbox name="email">Please send me email that is fun.</checkbox>

<button isdefault="true" onclick="parent.submitter.submit()">Submit</button>
</form>
</class>

<class name="mysecondform" extends="myForm" bgcolor="red">
<checkbox name="email" placement="checkboxPlace">another checkbox</checkbox>
</class>

<myForm />
<mysecondform />

</canvas>


This will work well if you define many "container views" in the parent for grouping controls, so you can control the placement of controls introduced in subclasses.

For you second question, there is plenty of into available in the developer's guide. Try these:

http://www.openlaszlo.org/lps4/docs/developers/tutorials/data-tutorial.html
http://www.openlaszlo.org/lps4/docs/developers/databinding.html

Robert
http://www.qrowd.com
http://www.cooqy.com

claudette
03-28-2008, 07:24 AM
thank you very much, Robert!!!

but how to do this more dynamically? how can I access to the nodes of my parent class?

rcyeager
03-28-2008, 08:02 AM
You can't inspect the view structure of a parent class at runtime unless there is an instance created.

Why use subclasses to position things differently? Is that the sole purpose of your subclasses?

It sounds like you are creating various forms. If those are dynamic in content, then why not define an XML metadata that defines the form contents and then read that via script to instantiate the views?

Robert
http://www.qrowd.com
http://www.cooqy.com