Friday, 15 January 2010

How do I map my HashMap in the ActionBean with the form on the JSP? -



How do I map my HashMap in the ActionBean with the form on the JSP? -

i using stripes. action bean has hashmap has id(string) , quantity(int). on jsp submitting form, id , quantity want map hashmap ids , quantity on form 'put' in hashmap. how do it?

i have done -

in actionbean(with getter , setter) -

private map<string, integer> productvariantmap = new hashmap<string, integer>();

on jsp -

<s:useactionbean beanclass="com.hk.web.action.core.b2b.b2baddtocartaction" var="atc"/> <s:useactionbean>

and picking values in onsubmit through loop , putting values like

${atc:productvariantmap.put(id, quantity)}; or $(atc.productvariantmap.put(id,quantity)};

none of these works. suggest me way map hashmap or add together these values per requirement. thanks.

this described in the documentation. have getter , setter map in yhe action bean, , have input fields in html form named productvariantmap['foo'] (foo beingness key of map).

so example, form containing next input fields populate map 1 key "foo", , 2 key "bar":

<input type="text" name="productvariantmap['foo']" value="1"/> <input type="text" name="productvariantmap['bar']" value="2"/>

jsp hashmap stripes

No comments:

Post a Comment