velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Katarzyna ChmurzyƄska <>
Subject Velocity, Struts, DynaValidatorForm and HashMap
Date Mon, 13 Dec 2004 23:25:52 GMT
I have problem in using all the thing above together:
what I want to do:

I have a template where are several text inputs, all of the same name (I 
don't know their number, but I want to validate them all in the same way)
They are for example numbers from 0 to 5 for some kind of products, but 
I also want to remember (in some way) in page the ID numbers for the 
So HashMap (where ID is key and number is value) would be the best.
There is no problem in prosessing values to the template, but is there 
any way to get all the keys and values for them, from the page sending a 
POST? can I get all the pairs from one HashMap object ?

eg. code:
_____ struts-config ______
<form-bean name="productsForm" type="DynaValidatorForm">
            <form-property name="products" type="java.util.HashMap"/>

______ template ______
#foreach ($key in $products.keySet())
   <input type="text" name="products" 

______ action ______
public ActionForward execute(ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response) throws IOException, 
          DynaActionForm f = (DynaActionForm) form;
          HashMap hm = f.get("products");

When I try so I always get :

ConversionException: Cannot assign value of type 'java.lang.String' to property 'products'
of type 'java.util.HashMap'

can anyone help me ???


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message