You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Oleg <ol...@gmail.com> on 2005/10/15 06:24:45 UTC

Dynamically sized Form problem: getting String[] from multiple select

I am setting up Dynamically sized  form with scope="request" so my
bean consists of 2 TreeMaps, one to display (fields objects: name,
type,...) and one to receive values from the form(values Strings). The
problem is that when form submitted I can only get one value as a
String and not String[] if its a multiple select box value.

struts-config.xml
-----------------------------------------
<form-bean name="dynamicHashmapForm"
type="org.apache.struts.validator.DynaValidatorForm">
     <form-property name="fields" type="java.util.TreeMap" />
<form-property name="values" type="java.util.TreeMap" />
   </form-bean>

here is how I get the values from the form:

		TreeMap values = (TreeMap)df.get("values");
		Iterator it = values.keySet().iterator();
		while (it.hasNext()) {
			String key = (String) it.next();
			String value = (String) values.get(key);
			System.out.println(key + ":" + value );
		}

If I attempt to get String[] instead of String, I get cast exception.
What can I do?

thanks,
Oleg

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