You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ezequiel Puig <e....@opodo.fr> on 2008/03/25 12:08:54 UTC
How to eliminate an entry from an array with s2 tags
Hi,
in my jsp, i have an array of ids and i will like to remove one of that
ids using s2 tags:
I have tried the following, but it doesn't work :(
<s:set name="allIDs" value="#parameters.productCode"/>
<s:set name="newID" value=""/>
<s:iterator value="#allIDs" status="stat">
<s:set name="myID" value="top"/>
<s:if test='%{ idToRemove != #myID }'>
<s:set name="newID[#stat]" value="#myID"/>
</s:if>
</s:iterator>
Does anyone know how to do it ?
thanks.
Ezequiel.
Re: How to eliminate an entry from an array with s2 tags
Posted by Dave Newton <ne...@yahoo.com>.
--- Ezequiel Puig <e....@opodo.fr> wrote:
> in my jsp, i have an array of ids and i will like to remove one of that
> ids using s2 tags:
>
> I have tried the following, but it doesn't work :(
> <s:set name="allIDs" value="#parameters.productCode"/>
> <s:set name="newID" value=""/>
> <s:iterator value="#allIDs" status="stat">
> <s:set name="myID" value="top"/>
> <s:if test='%{ idToRemove != #myID }'>
> <s:set name="newID[#stat]" value="#myID"/>
> </s:if>
> </s:iterator>
>
> Does anyone know how to do it ?
Depending on the underlying collection type you might get an exception.
You're not removing anything in the above code anyway, you're replacing a
value. You're also using the "status" value like it's an index, but it's not
[1].
But why? You'd have to work hard to convince me that the JSP is the place to
do something like that.
Dave
[1]
http://struts.apache.org/2.0.11.1/struts2-core/apidocs/org/apache/struts2/views/jsp/IteratorStatus.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org