You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ignacio de Córdoba <ic...@skios.es> on 2009/03/09 00:41:31 UTC

OGNL problem in s:checkbox

Hi there,
I am trying to activate some checkboxes if a certain condition is matched:

<s:checkbox name="activeServices"
value="%{userSession.portal.serviceNames.contains(service)}"
fieldValue="%{service}"/>

service is a String var which contains my site service names. I get it
iterating over a collection. checkbox should be checked when serviceNames
contains the String in "service" var.

It works OK if I replace "service" var with a string:
%{userSession.portal.serviceNames.contains('mail')}
but using avar won't work. Any idea why I can't replace "mail" literal with
a var there?

Thanks for any help,
Ignacio
-- 
View this message in context: http://www.nabble.com/OGNL-problem-in-s%3Acheckbox-tp22404619p22404619.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: OGNL problem in s:checkbox

Posted by justin2zj <ju...@163.com>.
   hi,i think i maybe like this:when you set a var attribute on the iterator,i was saved under top level in the ActionContext object,which contains ValueStack,parameters,attr,etc. 
  and when you refer the value using OGNL later,you have to  specify the data objects that you're refering,which by default is valuestack. you can specify #service or #attr.service. The attr will find any value match the name you specified throughout
the ActionContext.
    note that i am not really familiar with it,i hope it will do
some help.




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

Re: OGNL problem in s:checkbox

Posted by Ignacio de Córdoba <ic...@skios.es>.
Hi,
I fond the answer to my problem. Maybe it helps anyone here...

if "service" is the var from a s:iterator doing

%{serviceNames.contains(service)}

will not work but

%{serviceNames.contains(#attr.service)}

will work.

I don't know how. Must be related of how objects are set into OGNL
valueStack
-- 
View this message in context: http://www.nabble.com/OGNL-problem-in-s%3Acheckbox-tp22404619p22411372.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