You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bhaarat Sharma <bh...@gmail.com> on 2009/05/05 20:12:47 UTC
Arithmatic operations in Struts2 - ognl
Is there a way to do this in ognl?
I have the following code which works fine
First Name <s:property value="someList.get(0).name"/> Age: <s:property
value="someList.get(0).age"/>
Second Name <s:property value="someList.get(1).name"/> Age: <s:property
value="someList.get(1).age"/>
However the following line does not work.
Total Age <s:property value="#{someList.get(0).age +
someList.get(1).age}"/>
Is it possible to do arithmetic operations in ognl?
Re: Arithmatic operations in Struts2 - ognl
Posted by Bhaarat Sharma <bh...@gmail.com>.
thanks! thats better.
On Tue, May 5, 2009 at 2:34 PM, Dale Newfield <da...@newfield.org> wrote:
> Bhaarat Sharma wrote:
>
>> oh nevermind. got it.
>> Total Age <s:property value="someList.get(0).age + someList.get(1).age"/>
>>
>
> I really advise you to make that
> <s:property value="%{someList.get(0).age + someList.get(1).age}"/>
>
> If you have to remember which attributes are ognl expressions and which are
> not you will pull your hair out.
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: Arithmatic operations in Struts2 - ognl
Posted by Dale Newfield <da...@newfield.org>.
Bhaarat Sharma wrote:
> oh nevermind. got it.
> Total Age <s:property value="someList.get(0).age + someList.get(1).age"/>
I really advise you to make that
<s:property value="%{someList.get(0).age + someList.get(1).age}"/>
If you have to remember which attributes are ognl expressions and which
are not you will pull your hair out.
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Arithmatic operations in Struts2 - ognl
Posted by Bhaarat Sharma <bh...@gmail.com>.
oh nevermind. got it.
Total Age <s:property value="someList.get(0).age + someList.get(1).age"/>
simpler than I thought :)
On Tue, May 5, 2009 at 2:12 PM, Bhaarat Sharma <bh...@gmail.com> wrote:
> Is there a way to do this in ognl?
> I have the following code which works fine
>
> First Name <s:property value="someList.get(0).name"/> Age: <s:property
> value="someList.get(0).age"/>
> Second Name <s:property value="someList.get(1).name"/> Age: <s:property
> value="someList.get(1).age"/>
>
> However the following line does not work.
>
> Total Age <s:property value="#{someList.get(0).age +
> someList.get(1).age}"/>
>
> Is it possible to do arithmetic operations in ognl?
>