This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
AFAIK the result of getting a parameter like that will be an array, since a parameter can have multiple values.
As the developer, you have the power to check stuff like this yourself:The more important question is why you'd want to do this, since there's a built-in mechanism to make things like this much, much cleaner, and allow you to use the parameter as a real boolean.
Nick Sher
Ranch Hand
Joined: Nov 10, 2008
Posts: 78
posted
0
Sorry David, I've been travelling over the weekend. If I try to output the class the output is class [Ljava.lang.String;
I did not understand when you mentioned that I can use parameter as real boolean. What did you meant by that? Did you mean that I should have a getter and setter for the request parameter in the Action class?
So if you wanted to do a string compare, what would you need to do?
Ultimately, yes, I don't see any good reason to be comparing a request parameter directly in the JSP, and for something that's boolean, even less reason to be doing it as a String since the request will have already passed through the normal S2 interceptors, which will do the type conversion for you.
Nick Sher
Ranch Hand
Joined: Nov 10, 2008
Posts: 78
posted
0
Thanks for the pointer David. I eventually added a getter in my action class which is as shown below:
in JSP I do the following:
The false block never gets executed even when the request parameter is false. Not sure what I missed. Any idea?
This does look much cleaner.
Nick Sher
Ranch Hand
Joined: Nov 10, 2008
Posts: 78
posted
0
No problem. Figured that out. I now have a getter and setter in the action class, with a boolean property which has the same name as the parameter I was using. Now I dont have to do and getParameterAsString.