Reputation: 429
My problems is in a Struts2 action, where
I have a class :
public class MyAction<T> extends ActionSupport
with a private member like this :
private T myData;
And I would like to declare this aciton in the struts.xml file, how can i manage to do so ?
Thanks for the answer.
Ps : I've tried without declaration of T, but it did not work
Upvotes: 1
Views: 1123
Reputation: 76006
For example, you cannot obvioulsy write (in struts-XX.xml)
<action name="doSomething" class="xx.xx.MyAction<java.util.Date>">
But you can easily code a class (sort of alias) for each parametrization you intend to use.
public class MyAction_Date extends MyAction<java.util.Date> {}
and then :
<action name="doSomething" class="xx.xx.MyAction_Date">
Upvotes: 1
Reputation: 76006
In struts2 the action object is instantiated by the framework for each request. Then, I don't think you can use a parametrized class for that. (Except if struts allows you to specify a particular class parametrization, say MyAction<Date> , for a particular action mapping - I don't think it allows that)
Upvotes: 0