hezjing
Jun 7th, 2008, 02:47 AM
Hi
I have a command class that allows the user to enter an integer quantity value,
public class OrderCommand {
private int quantity;
// quantity in 6000 or 600
public void setQuantity(int quantity) {
this.quantity = quantity;
}
}
Then, my controller creates and returns the reference data like the following,
protected Map referenceData(HttpServletRequest request) throws Exception {
Map<Integer, String> quantities = new LinkedHashMap<Integer, String);
quantities.put(new Integer(6000), "6000");
quantities.put(new Integer(600), "600");
Map<String, Object> m = new HashMap<String, Object>();
m.put("quantities", quantities);
return m;
}
Here is what i coded in FreeMarker template, to allow the user to select the quantity of 6000 or 600 from radio buttons,
<@spring.formRadioButtons "${orderCommand.quantity}", quantities, "" />
Then, I encounter the following error when the page is being loaded,
Expected number, sequence, or string. options evaluated instead to freemarker.template.SimpleHash on line 272, column 26 in spring.ftl.
The problematic instruction:
----------
==> ${options[value]?html} [on line 272, column 24 in spring.ftl]
in user-directive spring.formRadioButtons [on line 32, column 5 in library.ftl]
...
Do you know what FreeMarker is giving me this error?
This problem is resolved if my controller creates a reference data of <String, String> instead of <Integer, String>
protected Map referenceData(HttpServletRequest request) throws Exception {
Map<String, String> quantities = new LinkedHashMap<String, String);
quantities.put("6000", "6000");
quantities.put("600", "600");
Map<String, Object> m = new HashMap<String, Object>();
m.put("quantities", quantities);
return m;
}
I have a command class that allows the user to enter an integer quantity value,
public class OrderCommand {
private int quantity;
// quantity in 6000 or 600
public void setQuantity(int quantity) {
this.quantity = quantity;
}
}
Then, my controller creates and returns the reference data like the following,
protected Map referenceData(HttpServletRequest request) throws Exception {
Map<Integer, String> quantities = new LinkedHashMap<Integer, String);
quantities.put(new Integer(6000), "6000");
quantities.put(new Integer(600), "600");
Map<String, Object> m = new HashMap<String, Object>();
m.put("quantities", quantities);
return m;
}
Here is what i coded in FreeMarker template, to allow the user to select the quantity of 6000 or 600 from radio buttons,
<@spring.formRadioButtons "${orderCommand.quantity}", quantities, "" />
Then, I encounter the following error when the page is being loaded,
Expected number, sequence, or string. options evaluated instead to freemarker.template.SimpleHash on line 272, column 26 in spring.ftl.
The problematic instruction:
----------
==> ${options[value]?html} [on line 272, column 24 in spring.ftl]
in user-directive spring.formRadioButtons [on line 32, column 5 in library.ftl]
...
Do you know what FreeMarker is giving me this error?
This problem is resolved if my controller creates a reference data of <String, String> instead of <Integer, String>
protected Map referenceData(HttpServletRequest request) throws Exception {
Map<String, String> quantities = new LinkedHashMap<String, String);
quantities.put("6000", "6000");
quantities.put("600", "600");
Map<String, Object> m = new HashMap<String, Object>();
m.put("quantities", quantities);
return m;
}