WebScripts

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Member II

WebScripts

I can successfully write a (e.g. MyWebScript1), which extends from AbstractWebScript.

However, my goal is to define another webscript (e.g. MyWebScript2), which will extend from MyWebScript1 (and MyWebScript1 will extend from AbstractWebScript).

The goal is to define MyWebScript1 as a base web script with some boiler plate/common code inside execute, which MyWebScript2, MyWebScript3 etc. can inherit (by calling super, without having to duplicate them in MyWebScript2, MyWebScript3).
MyWebScript1 will just serve as a superclass.
This is what I am not able to accomplish.

My questions:
1. Do I still need to define a XML for the common/base MyWebScript1? However, MyWebScript1 is not associated with any get, post etc.
2. Do I still need to define MyWebScript1 inside webscripts-context.xml?


I am only seen the examples where a given WebScript extends from AbstractWebScript, but seen a hirerachy like the way I am trying to accomplish.

3 Replies
Highlighted
Master

Re: WebScripts

You do not need any XML for any web script base class that is only used for others to extend from. If the base class defines a few setters for common members, you can define an abstract bean to be used as a "parent" for your specific web scripts.

Highlighted
Member II

Re: WebScripts

Tq very much Axel. Could you please provide any examples of code-snippets of parent declaration of parent in the webscript-context xml. Throughout my search, I can only find examples where all the webscripts only extend from AbstractWebScript, but do not find any example of two level of extending.

Highlighted
Master

Re: WebScripts

Really? All Java-backed webscripts typically have to use a parent to inherit key configuration. This pattern can simply be extended to use your base class as a (intermediary) parent.