How to declare a Generics Action in struts2.xml file?

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

Answers


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">

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)


Need Your Help

iOS custom keyboard memory constraints

ios ios-app-extension

Is there memory requirement set forth with custom keyboard extension? I recall reading somewhere that the keyboard can crash if you exceed a small amount of memory in your app.

GoogleMap API events click to zoom

javascript html google-maps google-maps-api-3 google-api

I am new to the Google Maps API v3 and new to Javascript in as well.