The following example: I have a superclass and subclass for a struts action.
The superclass defines @Results
, and the subclass needs to define additional specific @Result
entries. For example:
@Results({
@Result(name=BaseAction.ERROR, location="/WEB-INF/jsp/error.jsp")
})
public abstract class BaseAction extends ActionSupport implements ServletRequestAware {
...
}
..and a subclass
@Results({
@Result(name=BaseAction.INDEX, location="/WEB-INF/jsp/reporting/index.jsp")
})
public class ReportAction extends BaseAction {
...
}
My question is, does an instance of ReportAction only have the @Result
of INDEX
defined, or does it also contain any @Result
entries defined in any if it's superclasses.
Is my ReportAction
aware of the location set for BaseAction.ERROR
??
Thanks, Martin
The dispatcher result type is the default type, and is used if no other result type is specified. It's used to forward to a servlet, JSP, HTML page, and so on, on the server.
The method execute is where we placed what we want this controller to do in response to the hello. action . Method execute of HelloWorldAction. public String execute() throws Exception { messageStore = new MessageStore() ; helloCount++; return SUCCESS; }
ActionSupport class implements a no. of interfaces like Action, Validateable, LocaleProvider and Serializable etc. It is more commonly used instead of Action interface.
Yes, your ReportAction class will have both BaseAction.INDEX and BaseAction.ERROR.
General super class or sub class rule will apply in this case also. If you don't find something in your subclass it will go and look into the super class.
In your case BaseAction.ERROR not found in your subclass it will go and look into the superclass.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With