i'm writing the canonical survey app that everyone seems to write when they start with laszlo.
the xml has a format like this:
<surveys><survey><question><text>this is mult choice question</text><choices><choice>a</choice><choice>b</choice></choices></survey></surveys>
it works well but we would like to support freeform text (and maybe
other input types as well in the future).. we've added a 'type' on the question. if
type is 2 i would like to use an edittext component instead of a radiogroup.
<surveys><survey><question type='2'><text>this is a text only question</text></question></survey></surveys>
what is the cleanest way of doing this in lzx?
thanks
code:
<class name="surveydialog" extends="modaldialog"
title="Survey"
x="50"
y="50" width="500" height="400">
<attribute name="surveyNumber" value="1" type="string"/>
<Beeper id="beeper"/>
<view id="surveyView" datapath="${'surveyData:/surveys/survey['+parent.surveyNumber+']/question[1]'}">
<method event="oninit">
Debug.write(this.datapath.serialize());
</method>
<datapointer id="sDp" xpath="${'surveyData:/surveys/survey['+parent.parent.surveyNumber+']/question[1]'}">
<method event="ondata">
Debug.write(this.serialize());
</method>
</datapointer>
<simplelayout/>
<attribute name="questionId" value="$path{'@id'}"/>
<text id="t" text="$path{'text/text()'}" resize="true" multiline='true' width='450'/>
<radiogroup id="foo" name="votecombo"
layout="class: simplelayout; axis: y; spacing:6" x="5" y="5" width="130"
>
<radiobutton datapath="choices/choice" text="$path{'text()'}" value="$path{'text()'}"
selected="$path{'@selected'}">
<attribute name="answerId" value="$path{'@id'}"/>
<method event="onclick">
var d=canvas.datasets.surveyData;
var p=new LzParam();
p.addValue(parent.parent.questionId,this.answerId, true);
d.setQueryType("POST");
d.setQueryString(p); // 3c
d.doRequest();
if (sDp.selectNext()) {
surveyView.datapath.setPointer(sDp.p);
} else
{
surveyView.setVisible(false);
surveyConfirmView.setVisible(true);
}
</method>
</radiobutton>
</radiogroup>
<button>Previous Question
<method event="onclick">
if (sDp.selectPrev()) {
surveyView.datapath.setPointer(sDp.p);
}
</method>
</button>
<button>Next Question
<method event="onclick">
if (sDp.selectNext()) {
surveyView.datapath.setPointer(sDp.p);
} else
{
surveyView.setVisible(false);
surveyConfirmView.setVisible(true);
}
</method>
</button>
</view>
</class>
_______________________________________________ Laszlo-user mailing list [email protected] http://www.openlaszlo.org/mailman/listinfo/laszlo-user
