You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Mathew, Manoj" <Ma...@principal.com> on 2003/09/26 15:47:01 UTC

Is there a way to find an Object type? Please help

Hi

  I been using only String data types in my DynaAction form.But i had a requirement to use multi select options and i have to declare a String[] for it. the issue is i have my own method which maps the form element to the appropriate fields of my controller factory.there i have some code like this
public final static Collection transformFieldMap(DynaActionForm form) {
DynaClass dynaClass = form.getDynaClass();
		DynaProperty[] props = dynaClass.getDynaProperties();
		for (int i = 0; i < props.length; i++) {
			Object propertyNameObj = props[i].getName();

try {
				String fieldValue = (String) form.get(propertyNameObj.toString());
}catch (Exception e) {
				if (e instanceof ClassCastException) {
					String[] temp = (String[]) form.get(propertyNameObj.toString());
}}


}


I am assuming that i get this ClassCastException only when the form element is a String[].  I am live with this for now as i am using only one String[]  and rest are just String type.Is there anyway i can find whether the 'Object' is of type string[]  ??? I tried  with instance of and it is not working..

Thank you

Mathew Manoj
Group Information Systems (H243)
* (515)362-0539
* mailto:Mathew.Manoj@principal.com



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