Java generics are a compile-time feature only. The compiler uses your extra information (parameterized types) in order to detect some errors and eliminate the drudgery of some casting for you. However, when you run the JVM it has no knowledge of generics. Therefore, if you have an instance of List<User> it will just be "List" when it actually gets used. In this context, I do not believe that struts needs to know anything more than type="java.util.List" for it to work.

Cheers,

Mike
------------------------------------------------------------------------
Michael Taylor
TXE Systems, Inc.
[EMAIL PROTECTED]


Laurie Harper wrote:

I'd say it depends on how Struts processes the form bean declaration. Assuming it's using straight reflection, I don't see why generics wouldn't work.

However, Kent, you will need to correct your XML: the error you're seeing is becuase what you have can't be parsed (it's not well formed). Give this a try and see if it works:

  <form-property name="users"
    type="java.util.ArrayList&lt;testpackage.User&gt;"/>

L.

Nitesh Naveen wrote:

Generics is a Java 5.0 feature...
Don't think the features with 5.0 are introduced to Struts framework yet!


Thanks & Regards,
Nitesh
_____________________________

Disclaimer: Information contained and transmitted by this e-mail is confidential, proprietary, and legally privileged data of Cordiant Technologies that is
intended for use only by the addressee. If you are not the intended
recipient, you are notified that any dissemination, distribution, or copying of this e-mail is strictly prohibited and you are requested to delete this
e-mail immediately and notify the originator. Any views expressed by an
individual do not necessarily reflect the view of Cordiant Technologies. The recipient should scan this email and any attachments for viruses as Cordiant
Technologies is not liable for the presence of viruses in this email.
Cordiant Technologies does not accept liability for any errors or omissions as the internet communications cannot be guaranteed to be timely, secure, error or virus-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete.
To know more about Cordiant Technologies, please visit
http://www.cordiant.com
_____________________________


-----Original Message-----
From: Kent Boogaart [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 1:11 PM
To: user@struts.apache.org
Subject: Struts and Generics


Hi there,

I'm wondering whether it's possible to use generics with struts. Something
like:

<form-bean name="test" type="org.apache.struts.validator.DynaValidatorForm">
    <form-property name="users"
type="java.util.ArrayList<testpackage.User>"/>
</form-bean>

I tried doing this (with my class names of course) and I get this exception
on startup:
    javax.servlet.ServletException: Can't get definitions factory from
context.

Thanks,
Kent


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



Reply via email to