You got to include one more step as mentioned below.

Class classDefinition = Class.forName(ClassName_as_string);
Object obj = classDefinition.newInstance();
classDefinition afc = (obj)fm;

Anil.

-----Original Message-----
From: Andreas Hartmann [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 26, 2006 1:47 PM
To: user@struts.apache.org
Subject: dynamic casting in Action class

Hello!

I've got the following problem in an action-class: I dynamically want to
retrieve the ActionForm class, which has been called before the
Action-class.

Statically, I do this with
ActionFormClass afc = (afc)fm;


How is it done dynamically? I've got the String name of the desired
Class-Name in an Hashtable. I tried it with reflection, but stuck:

Class classDefinition = Class.forName(ClassName_as_string);
classDefinition afc = (classDefinition)fm;


The last line gives the error:

cannot find symbol classDefinition
symbol  : class classDefinition



Has anybody an idea, how to do it?

Thanks,
Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Information transmitted by this e-mail is proprietary to Infinite Computer 
Solutions and / or its Customers and is intended for use only by the individual 
or the entity to which it is addressed, and may contain information that is 
privileged, confidential or exempt from disclosure under applicable law. If you 
are not the intended recipient or it appears that this mail has been forwarded 
to you without proper authority, you are notified that any use or dissemination 
of this information in any manner is strictly prohibited. In such cases, please 
notify us immediately at [EMAIL PROTECTED] and delete this email from your 
records.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to