You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Alex Licota <al...@mail.com> on 2014/12/17 00:05:04 UTC

OGNL expression offset

Hi there,
I'm sorry if it's a dumb question but I'm having a really hard time figuring out what I'm doing wrong here.

I'm using OGNL 3.0.6 in a struts2 project and I get a constant offset in the value that I should get from the ognl expression.

One of my .jsp is iterating over a List(questions) of objects(question) to print radio buttons. When I submit a selected radio button, it maps either 1, 2 or 3 with the key question.id

<s:iterator value="questions" var="question" status="rowstatus">
	<p><s:property value="id" /></p>
	<p>
		<s:radio name="test['%{id}']" list="#{'1':''}" />
		<s:radio name="test['%{id}']" list="#{'2':''}" />
		<s:radio name="test['%{id}']" list="#{'3':''}" />
	</p>
</s:iterator>

Everything works except that the id I get from the OGNL EL is offset by 48 everytime... (e.g if the tag <s:property value="id" /> shows 5, I get 53 in my map key).

If someone could help me I would be really grateful.

Thanks :)

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


Re: OGNL expression offset

Posted by Alex Licota <al...@mail.com>.
Indeed, thanks a lot, the problem was with the ' '.

The correct EL is map[%{id}] and not map['%{id}']

You are awesome ! 

> Sent: Wednesday, December 17, 2014 at 12:16 AM
> From: "Bernd Eckenfels" <ec...@zusammenkunft.net>
> To: "Alex Licota" <al...@mail.com>
> Cc: user@commons.apache.org
> Subject: Re: OGNL expression offset
>
> Am Wed, 17 Dec 2014 00:05:04 +0100
> schrieb "Alex Licota" <al...@mail.com>:
> > Everything works except that the id I get from the OGNL EL is offset
> > by 48 everytime... (e.g if the tag <s:property value="id" /> shows 5,
> > I get 53 in my map key).
> 
> Sounds like you get the ASCII char value not the integer represented
> value.
> 
> Gruss
> Bernd
> 

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


Re: OGNL expression offset

Posted by Bernd Eckenfels <ec...@zusammenkunft.net>.
Am Wed, 17 Dec 2014 00:05:04 +0100
schrieb "Alex Licota" <al...@mail.com>:
> Everything works except that the id I get from the OGNL EL is offset
> by 48 everytime... (e.g if the tag <s:property value="id" /> shows 5,
> I get 53 in my map key).

Sounds like you get the ASCII char value not the integer represented
value.

Gruss
Bernd

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