ラジオボタンをBooleanで管理、表示をラベルで
意外と調べても載っていないんですね。。。
みんな困ってないんでしょうか?
Web的には良くあることだと思うんですが。
やりたいことは、
・ラジオボタン+ラベルで表示(男/女 みたいな)
・管理はBooleanで。確認画面での表示は文字列で行いたい
ということ。
s2jsf-exampleで試しました。
employeeEdit.html
<tr>
<td class="label">testRadio</td>
<td>
<input checked="checked" id="testRadio1" value="1" name="testRadio" type="radio" m:passthrough="true" class="right"/>テスト1
<input id="testRadio2" value="0" name="testRadio" type="radio" m:passthrough="true" class="right"/>テスト2
</td>
</tr>
*1
employeeConfirm.html
<tr>
<td class="label">testReadio</td>
<td><span m:value="#{employeeDto.testRadioStr}"></span></td>
</tr>
EmployeeDto.java
// TODO 初期化はコンストラクタでやったほうが良いか?
private Boolean testRadio = false;
private String testRadioStr;
private Map testMap;
public String getTestRadioStr()
{
return (String)this.testMap.get(testRadio);
}
*2
EmployeeEditActionImpl.java
private Boolean testRadio;
public void setTestRadio(Boolean radio)
{
this.employeeDto.setTestRadio(radio);
}
app.dicon
<component name="testMap" class="java.util.LinkedHashMap">
<initMethod name="put">
<arg>true</arg>
<arg>"テスト1"</arg>
</initMethod>
<initMethod name="put">
<arg>false</arg>
<arg>"テスト2"</arg>
</initMethod>
</component>
・・・これで出来たけど、もうちょっといい方法ないですかね?