Sunil Kumar Pissaye

Greenhorn
+ Follow
since Apr 22, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sunil Kumar Pissaye

Hi David,

I just tried the solution you suggested... works like a charm

This is a much cleaner design then what I was looking at... thanks a lot
14 years ago
Hi All,

This is more of a design question.. I am new to struts 2 and exploring different possibilities...
I have an application in which some of my JSP pages and actions need to have the user logged in...
The accepted way i see to do this is ... Login Interceptor - Put the interceptor on each action you want behind a login...

But, using an interceptor I cannot control access to my JSP's and have to add some code in the JSP to check if the user is logged in or not...
I thought the best way to do this would be to add <s:action name="checkLogin" /> as the very first line in the JSP.. this would call the action and re-direct if the user is not logged in... OR put the user object in session and check for each JSP check if the user object exists...

Is this the best way to go? and what is the point of creating an action class and an interceptor? Cant we create one piece of code which can check for both JSP's and Actions ?
Why cant an interceptor intercept a JSP ?
Pardon me if my questions seem naive...

Thank you.
14 years ago
after a lot of beating around.. i still cant get this to work....
i have given up and changed my database design...
14 years ago
Hi David,

I have now added a questionType attribute to the question class which will help me determine which subclass to instantiate....

But i am still struggling with creating the Type Converter...
I followed Ankit's advice and created a class QuestionTypeConverter which extends StrutsTypeConverter
When i configure TestAction-conversion.properties with
name=test.MyQuestionConverter
It works fine, but to intercept the arraylist it just doesnt seem to go through to the converter..
I tried using
questions=test.MyQuestionConverter
Element_questions=test.MyQuestionConverter
questions[]=test.MyQuestionConverter

I also tried
com.blah.Question=test.MyQuestionConverter

This also does not seem to work...

One More question here... I am using generics for the List declarations in the model class..
List<Question> questions = new ArrayList<Question>();

Does this in any way affect calling of the converter?
14 years ago
Hi David,
Yes and yes.. I have a default constructor.. and the increment also works properly...
I can add a property in the Question class QuestionType to find out what type of question is coming through...

But where do i find the correct class?

The ArrayList gets populated with Question objects... but apparently it does not know what to do with attributes that belong to subclasses, ex: blankAnswer

I need to somehow intercept the parameters and after comparing the 'questiontype' attribute, find out the correct class and put it back into the arraylist..

Is this possible? Or any workaround for this???

looks like a deadend
14 years ago
Thank you for your reply Ankit..

I am not able to get the converter to run..
I have created a custom type converter by extending StrutsTypeConverter..
Also created a file TestAction-conversion.properties
When I try to convert a property like name, it goes through the converter, ex: when i put this:
name=test.MyQuestionConverter

It works fine, but to intercept the arraylist it just doesnt seem to go through the converter..
I tried using
questions=test.MyQuestionConverter
Element_questions=test.MyQuestionConverter
questions[]=test.MyQuestionConverter

None of these work! How do i get the converter to be called for an ArrayList ???
14 years ago
Howdy fellow ranchers,

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....




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.

14 years ago