struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeromy Evans <jeromy.ev...@blueskyminds.com.au>
Subject Re: Ognl expressions in Struts 2.1
Date Mon, 07 Apr 2008 03:49:46 GMT
In addition to Wes' comment, as you're using display:table and have used 
the uid attribute, the current row of the table is placed into the 
PageContext.

You can access the page context in OGNL via #attr, so your expression 
becomes this:

<s:checkbox name="checkBox" id="checkBox" value="cdUsuario" fieldValue="%{#attr.item.id}"
theme="simple" onclick="confirmAllChecked()" />


Wes Wannemacher wrote:
> Your problem isn't OGNL in parameters, you are using EL in your
> examples. By default, EL expressions are disabled, but you could easily
> switch your expressions to OGNL. I'm guessing that if you use '%'
> instead of '$' it will probably work. If your action has a getItem(),
> and the returned object has a getId(), then %{item.id} should work, and
> if the %{ and } may not even be necessary. 
>
> ${ triggers EL expression parsing, but this is done by the app server,
> if the TLD specifies that the attribute accepts EL (which struts tags do
> not by default, unless you change the TLD which isn't advisable). 
>
> %{ forces OGNL expression. OGNL expression evaluation happens within the
> tag's code, so the app server knows nothing about this step. Thus, the
> TLD file's directives have nothing to do with this parsing. Many of the
> Struts 2 tag's attributes will attempt to parse parameters as OGNL by
> default, but %{ will force parsing.
>
> -Wes
>
>
> On Sun, 2008-04-06 at 21:19 -0300, Márcio Gurgel wrote:
>   
>> Hi all,
>>
>> I was using struts 2.0.9, then I resolved to upgrade to 2.1.0.
>> I was setting a value in a checkbox like this:
>> <s:checkBox value="${currentRow.id}"/> inside a displayTag iterator.
>>
>> I read this link https://issues.apache.org/struts/browse/WW-2107 and
>> understood the situation.
>> But, is there another way to set a value in my checkBox?
>>
>> <display:table requestURI="/usuario/pesquisar.action" name="listUsuPesquisa"
>> list="listUsuPesquisa" export="false" class="list" pagesize="15" uid="item">
>>
>> <display:column title='<input type="checkbox" name="selectAll"
>> id="selectAll" value="" onclick="checkAll()"/>'>
>> <s:checkbox name="checkBox" id="checkBox" value="cdUsuario" fieldValue="${
>> item.id}" theme="simple" onclick="confirmAllChecked()" />
>> </display>
>>
>> *Exception*
>> According to TLD or attribute directive in tag file, attribute fieldValue
>> does not accept any expressions
>>
>> Tanks a lot!
>> Have a nice week!
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>   


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


Mime
View raw message