You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Greg Lindholm <gl...@yahoo.com> on 2009/04/10 03:24:55 UTC

[S2.1.6] boolean static parameter for an action

I'm trying to pass a boolean "static" parameter to an Action and the value getting set is always "false" no matter what I do it won't set it to "true".

<action name="MyAction"
          class="com.xxx.MyClass"
          method="doDisplay">
          <param name="xxx">${true}</param>
          <result>/struts/xxx.jsp</result>
          <result name="notFound" type="redirectAction">OtherAction</result>
</action>

I put a break point in setXxx(boolean x)  and it always gets called with x= 'false'.

I have tried different value expressions "${true}" and "true" and "1" and "${1}" and "${1==1}" 
and always get 'false' in the action setter.
There is no other 'xxx' parameter which is overriding it, if I remove the param element then the setter doesn't get called at all.

Is this a bug or is there some other magic to get 'true' passed?




      

Re: [S2.1.6] boolean static parameter for an action

Posted by Greg Lindholm <gl...@yahoo.com>.
OK things are just getting weirder...

I've been in the debugger and found that  StaticParametersInterceptor needs
to have the parameter 'parse' set to 'true' (it defaults to 'false').  If I
set parse=true then it will parse the "${'true'}" value string and correctly
call the setter with value 'true'.   I can't imagine why you would ever want
this set to false unless all your parameters are strings, yet that's the
default.

But there is still a problem...

I'm using a paramsPrepareParamsStack stack, so it first does the
staticParams interceptor and calls the setter with 'true' then the next
interceptor is 'params' and it again calls the setter but this time with
'false'.  

BTW it doesn't look like the first 'params' interceptor is doing anything so
the setter has not been called before the prepare interceptor is run, this
is not effecting me but seems wrong, seems like 'staticParams' should be
before prepare interceptor.

I broke at the setter in the debugger and see that the second call is coming
from ParametersInerceptor.setParameters()  and it has the value of
"${'true'}" which is the raw, unevaluated, unparsed, value string.  

So staticParams is now correctly setting the value to 'true' and params
interceptor is overriding it and setting it back to 'false'.

Help!



Greg Lindholm wrote:
> 
> My reply got messed up so here it is again....
> 
> When I try ${'true'} and the setter is still called with 'false'. 
> 
> 
> 2009/4/10 Greg Lindholm <gl...@yahoo.com>:
>> I'm trying to pass a boolean "static" parameter to an Action and the
>> value getting set is always "false" no matter what I do it won't set it
>> to "true".
>>
>> <action name="MyAction"
>>           class="com.xxx.MyClass"
>>           method="doDisplay">
>>           ${true}
> 
> try
> ${'true'}
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2.1.6--boolean-static-parameter-for-an-action-tp22981740p22992899.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2.1.6] boolean static parameter for an action

Posted by Greg Lindholm <gl...@yahoo.com>.
My reply got messed up so here it is again....

When I try ${'true'} and the setter is still called with 'false'. 


2009/4/10 Greg Lindholm <gl...@yahoo.com>:
> I'm trying to pass a boolean "static" parameter to an Action and the value
> getting set is always "false" no matter what I do it won't set it to
> "true".
>
> <action name="MyAction"
>           class="com.xxx.MyClass"
>           method="doDisplay">
>           ${true}

try
${'true'}


-- 
View this message in context: http://www.nabble.com/-S2.1.6--boolean-static-parameter-for-an-action-tp22981740p22992109.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2.1.6] boolean static parameter for an action

Posted by Greg Lindholm <gl...@yahoo.com>.


Lukasz Lenart wrote:
> 
> 2009/4/10 Greg Lindholm <gl...@yahoo.com>:
>> I'm trying to pass a boolean "static" parameter to an Action and the
>> value getting set is always "false" no matter what I do it won't set it
>> to "true".
>>
>> <action name="MyAction"
>>           class="com.xxx.MyClass"
>>           method="doDisplay">
>>           ${true}
> 
> try
> ${'true'}
> 
> 
> Regards
> -- 
> Lukasz
> http://www.lenart.org.pl/
> 
> 

Nope, I try ${'true'} and the setter is still called with 'false'.
 

-- 
View this message in context: http://www.nabble.com/-S2.1.6--boolean-static-parameter-for-an-action-tp22981740p22992070.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2.1.6] boolean static parameter for an action

Posted by Lukasz Lenart <lu...@googlemail.com>.
2009/4/10 Greg Lindholm <gl...@yahoo.com>:
> I'm trying to pass a boolean "static" parameter to an Action and the value getting set is always "false" no matter what I do it won't set it to "true".
>
> <action name="MyAction"
>           class="com.xxx.MyClass"
>           method="doDisplay">
>           <param name="xxx">${true}</param>

try
${'true'}


Regards
-- 
Lukasz
http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org