如果我想一個h:selectmanycheckbox
的價值屬性綁定到一個地圖,用JSF 2.0.3的裏我會做類似下面ICEfaces的2測試版1:結合selectmanycheckbox到地圖引發轉換錯誤
豆:
private Map<String, String[]> values = new HashMap<String, String[]>();
public Map<String, String[]> getValues() {
return values;
}
public void setValues(Map<String, String[]> values) {
this.values = values;
}
和XHTML頁面:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<h:selectManyCheckbox
id="test"
value="#{testController.values['foo']}">
<f:selectItem itemLabel="1" itemValue="1_1" />
<f:selectItem itemLabel="2" itemValue="1_2" />
<f:selectItem itemLabel="3" itemValue="1_3" />
<f:selectItem itemLabel="4" itemValue="1_4" />
</h:selectManyCheckbox>
<h:commandButton value="Send" />
</h:form>
</h:body>
這可以正常工作,但在我的應用程序中,我需要對每個複選框的位置進行更多控制,因此我將標準<h:selectManyCheckbox>
標籤替換爲其相應的冰面標籤<ice:selectManyCheckbox>
和<ice:checkbox>
。
豆子保持不變和XHTML的網頁現在看起來像這樣:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<ice:selectManyCheckbox
id="test"
layout="spread"
value="#{testController.values['foo']}">
<f:selectItem itemLabel="1" itemValue="1_1" />
<f:selectItem itemLabel="2" itemValue="1_2" />
<f:selectItem itemLabel="3" itemValue="1_3" />
<f:selectItem itemLabel="4" itemValue="1_4" />
</ice:selectManyCheckbox>
<table border="1">
<tr>
<td><ice:checkbox id="c1" for="test" index="0" /></td>
<td><ice:checkbox id="c2" for="test" index="1" /></td>
</tr>
<tr>
<td><ice:checkbox id="c3" for="test" index="2" /></td>
<td><ice:checkbox id="c4" for="test" index="3" /></td>
</tr>
</table>
<h:commandButton value="Senden" />
</h:form>
</h:body>
現在,每當我送的形式,我得到一個轉換錯誤,我想不通爲什麼。
如果我將<ice:selectManyCheckbox>
的值屬性綁定到一個簡單的stringarray,它會分叉,但是因爲我不知道有多少checkbox組,我需要它來處理一個map。
我在tomcat 6.0.26上使用了icefaces 2.0.0 beta 1和sun ri 2.0.3以及el 2.2。
有沒有人知道我的問題的解決方案?
這似乎是做的伎倆,但考慮到我不必這樣做與ri,我想它可以被視爲一個錯誤。 – greg 2010-07-28 07:13:44
也許你可以bugreport這個......他們喜歡在beta階段閱讀bugreports :) – 2010-07-28 08:34:22