There's an example in the link I posted a week ago. If you don't understand it or are having trouble implementing one of your own, you must Tell the Details of your code and configuration in order for use to help you.
Second - also in the <interceptors> section, you need to define an interceptor stack that includes your interceptor. When you define your stack you will need to include references to any struts interceptors or interceptor stacks that you want to run since you will be overridding the default stack. Something like this:
Can you tell me how should i implement MyAction(which has setDate Method) of interceptor class ??
I'm a bit confused on how to proceed for this.??
Help provided will be highly appreciated.
-- Deepak Lal
Joined: Aug 29, 2008
Hi Deepak, I don't understand what you are asking. What do you mean by "implement" your action class? The code you have for the interceptor looks correct to me. Are you getting an error from it? Is it not doing what you expect it to?
Originally posted by Tom Rispoli: Hi Deepak, I don't understand what you are asking. What do you mean by "implement" your action class? The code you have for the interceptor looks correct to me. Are you getting an error from it? Is it not doing what you expect it to?
Dear Tom Rispoli,
Please find my comments below.
My Question here goes as follows. MyAction in the above code is a class which has setDate method which takes date as an argument.so i wanted to know how to write the code for class "MyAction" ??
i.e Is MyAction class a built in class as part of any package ??? (or) Should we provide setters/getters for date in MyAction class ???
hope you understand now???
Please let me know the logic for MyAction class which has setDate(new Date()) as an argument.
Your sample interceptor code has the following line:
That sort of implies the action will have a setDate(Date) method, yes? So write that method.
Joined: Aug 29, 2008
MyAction is a class that you define. Its one you should have already defined. When you set up your struts.xml file you specify which class will be used to process each action in the file. The class you are getting a reference to in the interceptor is an instance of the action class for your action. So you should be able to cast it to the type of your current action or any of its parent classes. In my application my custom interceptor runs for all actions so I have it get a reference to a parent class that I created for all of my actions.