Is is possible to have a action form bean which will have common form elements and have separate action form beans for each kind of report that will inherit the base action form and use the form elements.
If yes, do I have to have the base action form entry in struts-config.xml
Same question with Action class. Can I have a base action class and have report specific action classes that inherit the base action class. because in my case for every report that the application needs to generate it has to check roles that will be available in request cookies. (jaas roles is not possible in this case. has to be request cookies) can I have that functionality in base action class and have report specific actions in their respective action classes. And also what configuration needs to be done in struts-config.xml
Yes, it certainly is possible to use inheritance for both an ActionForm bean and an Action class.
For an action form, the process is:
Write your base class with the shared properties and their getters and setters. This class should extend ActionForm
Write your subclasses extending your base class with the added properties and getters and setters
Make an entry in struts-config.xml for each subclass. There is no need to put the base class anywhere in struts-config.xml
For an Action class, the process is:
Write your base class extending Action. Your execute method should contain logic that is performed for all actions. My suggestion is to make it return null if everything is OK, and have it return an ActionForward to an error page if it encounters an error.
Write your subclasses extending your base class. The execute method should start with:
ActionForward forwardFromBase = super.execute(<list all parms>); if (forwardFromBase != null) return forwardFromBase():
The rest of the execute() method should contain logic unique to each subclass
Make an entry in struts-config.xml for each action. There is no need to put the base class anywhere in struts-config.xml
Good luck! [ June 10, 2005: Message edited by: Merrill Higginson ]