velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Katarzyna ChmurzyƄska <k...@gazeta.pl>
Subject Velocity, Struts, DynaValidatorForm and HashMap
Date Mon, 13 Dec 2004 23:25:52 GMT
Hi,
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 
products.
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"/>
</form-bean>

______ template ______
#foreach ($key in $products.keySet())
   <input type="text" name="products" 
value="$productsForm.products.get($key)"/>
#end

______ action ______
public ActionForward execute(ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response) throws IOException, 
ServletException
    {
          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 ???

kate



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message