struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julie.Hu...@mizuhocbus.com
Subject Re: Is there a way to find an Object type? Please help
Date Fri, 26 Sep 2003 15:12:45 GMT
"Mathew, Manoj" <Mathew.Manoj@principal.com>
09/26/03 09:47 AM
Please respond to "Struts Users Mailing List"

 
        To:     "Struts Users Mailing List" <struts-user@jakarta.apache.org>
        cc: 
        Subject:        Is there a way to find an Object type? Please help
 
String fieldValue = (String) form.get(propertyNameObj.toString())?

I guess this always returns String no matter what, 'cause you use 
propertyNameObj.toString().




================
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





= = = = = = = = = == = = = = = == = = = = = = = == = = = = = == = = = = 
This transmittal and any attachments may contain confidential, privileged or sensitive information
and is solely for the use of the intended recipient. If you are not intended recipient, you
are hereby notified that you have received this transmittal and any such attachments in error
and any review, dissemination, distribution or copying thereof is strictly prohibited. If
you have received this transmittal and any attachments in error please notify the sender and
immediately destroy the message and all its attachments. Any opinions herein expressed may
be those of the author and not necessarily of Mizuho Corporate Bank, Ltd (the "Bank"). The
Bank accepts no responsibility for the accuracy or completeness of any information herein
contained.
= = = = = = = = = == = = = = = == = = = = = = = == = = = = = == = = = = 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message