select - Tapestry: default value for a dropdown component -
i use following code select-component:
java-class:
@component(parameters = {"blankoption=auto", "model=somemodel", "value=someid", "zone=somezone"}) private select demoselect;
template:
<select t:id="demoselect" />
this gets rendered following:
<select id="demoselect" name="demoselect"> <option value=""></option> <option value="1">first</option> <option value="2">second</option> <option value="3">third</option> </select>
the behavior i'm looking is, option preselected (this should decided in page class). how can configure in tapestry? need tell tapestry render "selected" appropriate option, e.g.:
<select id="demoselect" name="demoselect"> <option value=""></option> <option value="1">first</option> <option value="2" selected="selected">second</option> <option value="3">third</option> </select>
does suffice alter model (i don't think so), or have extend select-component itself. have found this article, looked quite promising, unfortunately links source codes dead.
there no need extend anything. setting property value before rendering trick:
@property private sometype someid; @setuprender void initsomeid() { if (this.someid == null) { this.someid = this.getdefaultvalueforsomeid(); } }
Comments
Post a Comment