struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alberto A. Flores" <aaflo...@gmail.com>
Subject Re: Runtime Expressions within Tag
Date Mon, 10 Dec 2007 19:10:25 GMT
Thanks Wes,

No offense to this approach, but is this the only way to do additions 
(and for this matter, any other operations) within a struts2 tag?. This 
is simply not clean (e.g. adding a property to my action for a counter, 
etc).

Thanks anyway!

Alberto

Wes Wannemacher wrote:
> #request.foo is going to evaluate as a j.l.String. If your action has
> a getter for foo, then just refer to it as "%{foo + 1}", conversely,
> if you are feeling confident, you can make a static call to parse it -
> "%{@java.lang.Integer@parseInt(#request.foo) +1}"
> 
> -Wes
> 
> On 12/10/07, Alberto A. Flores <aaflores@gmail.com> wrote:
>> I'm currently migrating an app from Struts 1.x to 2.x and encounter this
>> situation where I was calculating the tabIndex of a JSP on the fly
>> (reusable JSP). In struts 1.x this was done using
>>
>> <c:set var="tabIndexCount" value="<%= request.getParameter("foo") %>"/>
>> ...
>> <html-el:text tabIndex="${tabIndexCount + 1}" ... />
>>
>>
>> According to the Struts2 documentation, non-string attributes are
>> evaluated as expressions, so the following:
>>
>> <s:textInput tabIndex=""%{#request.foo + 1}/>
>>
>> should do the work, but instead the above code is *appending* a 1
>> (string concatenation). Am I missing something or this is a bug? Any ideas!
>>
>>
>> --
>>
>> Alberto A. Flores
>> http://www.linkedin.com/in/aflores
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
> 
> 

-- 

Alberto A. Flores
http://www.linkedin.com/in/aflores



Mime
View raw message