struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laetitia DUBY <>
Subject Using Java Generics in Struts Actions
Date Sun, 12 Jul 2009 11:30:17 GMT
Hi all !

I'm new to Struts2 and I'm starting with implementing a simple app. So
far, everything was fine. But now I want to complexify a bit by
introducing java generics (to prevent from repeating same treatments
in several classes) and integrating with Spring.

I tried writing a GenericAction which has 2 parameterized type (one
for the service used, one for the generated object from the form) and
which contains all basic methods for saving, deleting, updating,
listing objects (but with parameterized types). Then I wrote an action
which extends this GenericAction, the 2 types are passed in argument
in the extends statement.

The struts.xml config file references the later one and I have an
additional constant declaration to use Spring : <constant
name="struts.objectFactory" value="spring" />.

When I fill in the form and call the save.action, I get the following
error: ognl.NoSuchPropertyException:

This tells me that Struts (or Spring) do not create the right type of
object and is then not capable to set the properties. But I don't
understand why. I tested the generics principle with simple classes
(MyBox extends Box<Integer>, where Box<T> is a generic class) and when
I create a MyBox object in a main function, the property has the right
type (Integer).

Can you help me to point out where is the problem ? Am i missing
something with the generics or is it a configuration problem with
Struts (or Spring) ?

Many thanks in advance for your help.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message