если я хочу привязать атрибут значения h:selectmanycheckbox к карте, с помощью ri jsf 2.0.3 я бы сделал что-то вроде следующего
Боб:
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> их эквивалентами icefaces <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>
Now whenever I send the form I get a conversion-error and I can't figure out why.
Если я привяжу атрибут значения <ice:selectManyCheckbox> к простому массиву строк, он отлично разветвится, но, поскольку я не знаю, сколько групп флажков будет, мне нужно, чтобы он работал с картой.
Я использую icefaces 2.0.0 beta 1 вместе с sun ri 2.0.3 и el 2.2 на tomcat 6.0.26.
Кто-нибудь знает решение моей проблемы?