Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to have Common base class for classes extending Action and DispatchAction Classe

 
ajit alwe
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have common code, which will be used by all the classes extending Action and DispatchAction Classes in the application.
If there is only one base class extending DispatchAction class, then all the classes which wants to use only Action class features will be forced to configure
1)'parameter' attribute in the action element in the struts-config.xml and 2) supply 'parameter' information through the HTTP request.

To Avoid this i will have to use two base classes with same code. one extending Action class and the other extending <br>ActionDispatch.
 
David Yutzy
tumbleweed and gunslinger
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you trying to accomplish by doing this? What scenario is causing you to have to split the logic in this way?
 
ajit alwe
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David Yutzy:
What are you trying to accomplish by doing this? What scenario is causing you to have to split the logic in this way?

Thanks for the reply:
There are two kinds of action handler in the application:
1) Extending Action class
2) Extending ActionDispatch class
I have identified some common code used by all the action handler classes. Which will be put in base class.
If i have common base class 'BaseActionDispatch' extending ActionDispatch, for above two classes. Then classes which were earlier extending Action
class, now needs to provide following information,
1) 'parameter' attribute in the action element of the struts-config.xml file
2) the value of the 'parameter' and the method name needs to be appended to the url in every request send to the action handler classes.
Eg:
struts-config.xml
<action path="/test" type="MyDispatchAction" parameter="method" >
url:
<a href="testLog.do?method=test"> call DispatchAction</a>
This is required because the Base class is extending ActionDispatch, which makes it Mandatory to provide above 2 information.
But above 2 information is redundant for those classes which were earlier extending Action class, but they need to provide as they are now extending BaseActionDispatch class.
If i don't provide the first information. i get the following error
"DispatchAction - -DispatchMapping[/test] does not define a handler property"
(i am using in jdeveloper9.0.3)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic