You can't do either of these things! AFAIK you can't do dynamic casting in java, although in java 5 you may be able to utilise the Class.cast method.
Gareth Anil Kumar T wrote:
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]
-- Gareth Evans Software Developer MSoft eSolutions Limited Technology Centre Inward Way Rossmore Business Park Ellesmere Port Cheshire CH65 3EN -- Tel: +44 (0)870 0100 704 Fax: +44 (0)870 9010 705 E-Mail: [EMAIL PROTECTED] Web: www.msoft.co.uk ---------------------------------------------- Terms: Please note that any prices quoted within this e-mail are subject to VAT. All program details and code described in this e-mail are subject to copyright © of MSoft eSolutions Limited and remain the intellectual property of MSoft eSolutions Limited. Any proposal or pricing information contained within this e-mail are subject to MSoft eSolutions' Terms and Conditions ---------------------------------------------- Disclaimer: This message is intended only for use of the addressee. If this message was sent to you in error, please notify the sender and delete this message. MSoft eSolutions Limited cannot accept responsibility for viruses, so please scan attachments. Views expressed in this message do not necessarily reflect those of MSoft eSolutions Limited who will not necessarily be bound by its contents. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]