I have a JSF2 application that uses Spring 3.0. I have a bean that has a type property List<Double>with 5 elements:
public class MyBean {
private List<Double> values;
public List<Double> getValues() {
if (values == null) {
values = new ArrayList<Double>(5);
for (int i = 0; i < 5; i++) {
values.add(null);
}
}
return values;
}
public void setValues(List<Double> values) {
this.values = values;
}
}
In my xhtml file, I have this for each element:
<h:inputText id="value1" value="#{myBean.values[0]}">
<f:convertNumber pattern="#########0.##" />
</h:inputText>
My goal is to get values ββlike ArrayList. In addition, I do not want to maintain individual properties for each participant. A future requirement will cause the total number of values ββto be dynamic (rather than hardcoded 5), so I can use a loop to determine the inputs for each element, but now we will not focus on that.
, . , . , 1, 2.0, 3 ( 2 , ), [1, "2.0", 3, "," "], 1 3 BigDecimal, 2.0, 2 - . ClassCastexception , , , Double. BigDecimal Double; , . , . , , Double. :
<h:inputText id="value1" value="#{myBean.values[0]}">
<f:converter id="javax.faces.Double" />
</h:inputText>
:
<f:converter> Default behavior invoked of requiring a converter-id passed in the constructor, must override ConvertHandler(ConverterConfig)
, JSF, , .