I iterated over a list of KeyValuePair objects (get/set for properties key and value).
This list was initialized as
List<KeyValuePair> kvp = new ArrayList<KeyValuePair>();
kvps.add(new KeyValuePair("aaa","111");
kvps.add(new KeyValuePair("bbb","222");
The list was retrieved from a page bean named "tb" returned from the action. The "tb" obejct has a getKvp() : List<KeyValuePair> method.
Displayed output in
jsp using:
<s:iterator value="tb.kvp" status="stat">
<b>Key: </b><s:textfield name="key" value="%{key}" /><br>
<b>Value: </b><s:textfield name="value" value="%{value}" /><br>
<hr>
</s:iterator>
Resulting in two groups of text fields. A key textfield and a value textfield followed by a ruled line then another group of key textfield and value textfield. All four fields were properly initialized.
On the page, I changed the value in the first key textfield from "aaa" to "ccc" and the first value field from "111" to "333" and submitted the form. When the List of KeyValuePair objects was added to the "tb" page bean and stored in the action, there were four KeyValuePair objects in the list. when printed out we see:
Key: "ccc" Value: null
Key: "bbb" Value: null
Key: null Value: "333"
Key: null Value: "222"
It is creating one KeyValuePair object for each textfield displayed even though OGNL originally created the displayed output with the values for two textfields from each KeyValuePair object.
Does anyone know how to group each key and value textfield combination together so that both values get added to one KeyValuePair object instead of one per KeyValuePair?
any help would be greatly appreciated.
Thanks,
Pete Searls