My subject line may not be close to the problem.... I will go straight into
code so i can explain my problem clearly...
I have an action class which looks like this:
Please note, I have left out all the getter and setter methods....
public class TestAction extends ActionSupport { private String name; private List<Question> questions = new ArrayList<Question>(); public String createTest() throws Exception{ //code to get questions out of arraylist } } //The model class Question looks like this: public class Question{ private String questionText; } public class FillBlankQuestion extends Question{ private String blankAnswer; } //My JSP Form looks somethin like this: <s:form action="createTest.action"> <s:textfield name="name" label="Name of the Test" /> <s:textfield name="questions[0].questionText" label="The Question" /> <s:textfield name="questions[0].blankAnswer" label="The Answer for the blank" /> <s:submit value="Create Test" /> </s:form>
When i run this, I get an error which says
ERROR: ParametersInterceptor - [setParameters]: Unexpected
Exception caught setting questions[0].blankAnswer' on 'class
com.mtg.action.TestAction: Error setting expression
questions[0].answer' with value '[Ljava.lang.String;@2c06b2'
The questions in the jsp page are being added using javascript and
each question can be of a different type.. for example, first question
is FillBlankQuestion, the next one can be EssayQuestion (which also
extends Question)..
Now, I know that the arraylist has Question objects and not
FillBlankQuestion objects... But there must be a way for me to
intercept setting of objects in the arraylist...
I dont know how to use interceptors.. but somehow have the feeling the
solution lies in interceptors...
I cant change the way questions are added because the model is from
hibernate....
Please help me out with this.. I am losing my hair....
Thank you.
Bollywood news, movie reviews, film trailers and more! Go to
http://in.movies.yahoo.com/