Hi Dave,

Thanks for your reponse. Anyway, I will try to convince you ;)

Some background: i have a page where a list of products are shown. In that page 
there is a button to compare products. What the button does is collect all the 
selected product's id and call an action: 
CompareProducts.do?productID=111&productID=222 etc. As the product selection is 
done by the user, the complete url is created with javascript :(. Consequently, 
the action CompareProducts has an array like that: String[] productID. So, when 
the action returns the page, i can access the array productID.
What i want to do is to put an button in the comparation page that allows the 
user to deselect a product. So, i need to call the action CompareProducts with 
all the ids (productID) removing the product's id that has been deselected.
And i want to do that with s2 tags and not with javascript.

Well, i hope it's a little bit more clear.

Thanks,

Ezequiel.


-----Message d'origine-----
De : Dave Newton [mailto:[EMAIL PROTECTED] 
Envoyé : mardi 25 mars 2008 13:08
À : Struts Users Mailing List
Objet : Re: How to eliminate an entry from an array with s2 tags


--- Ezequiel Puig <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to