tapestry radio group
I am unable to get the tapestry 4 radio group working.
My HTML
<td><span jwcid="activeServerRadioGroup"></span></td>
<td><input type="radio" jwcid="activeServerRadio" /></td>
开发者_JS百科
My .page
<property name="activeServer"/>
<component id="activeServerRadioGroup" type="RadioGroup">
<binding name="selected" value="activeServer.selected"/>
</component>
<component id="activeServers" type="For">
<binding name="source" value="activeServers"/>
<binding name="keyExpression" value="literal:id"/>
<binding name="value" value="activeServer"/>
<binding name="element" value="literal:tr"/>
</component>
<component id="activeServerRadio" type="Radio">
<binding name="value" value="activeServer.id"/>
</component>
In my .java file I have a method getActiveServers() that returns a list of custom class with selected, id attributes. The above structure is not working. Can somebody help?
You did not describe your problem in much detail, but here's my guess:
1. Radio must be put inside a RadioGroup
<span jwcid="activeServerRadioGroup">
<tr jwcid="activeServers">
<td><input type="radio" jwcid="activeServerRadio" /></td>
</tr>
</span>
2. The "selected" parameter of RadioGroup must be set to a server id
<component id="activeServerRadioGroup" type="RadioGroup">
<binding name="selected" value="activeServerId"/>
</component>
And in your page class:
public ... getActiveServerId()
{
// Return the id of the active server
}
3. Perhaps you should not even be using RadioGroup?
RadioGroup is only used to select one single object from a list. From your description it sound like you can have several active servers at a time. In that case, perhaps a list of checkboxes would be better?
精彩评论