cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derek Hohls" <DHo...@csir.co.za>
Subject Re: iteration problem with flow
Date Mon, 08 Nov 2004 07:11:57 GMT
Something else to add to the docs ;-)

>>> jc.textor@gmx.de 2004/11/06 02:28:21 PM >>>
Hi Andrew,

not sure about this but cocoon behaves the following way for multiple 
checkboxes:

- if no checkbox is selected, you get no value, i.e. 
cocoon.request.get("delItem") is null.
- if one checkbox is selected, you get a simple value, i.e. 
cocoon.request.get("delItem") is  for example "5".
- if two or more checkboxes are selected, you get an instance of 
java.util.List

Only in the latter case you can use the iterator function. In the first

two cases, items.iterator() will
be undefined. So you should actually do some pre-processing like this
to 
have a list in any case:

var items = new java.util.Vector();

if(cocoon.request.get("delItem"))
    if(cocoon.request.get("delItem").iterator) // no brackets, this
just 
checks if it has an iterator at all
       items.addAll(cocoon.request.get("delItem"));
    else
       items.add(cocoon.request.get("delItem"));

This is a little nasty sometimes, but I guess it can't be implemented 
differently in cocoon.

HTH,
Johannes


beyaNet wrote:

> Hi,
> I have an html form which has a number of checkboxes which when 
> selected indicate that the item should be deleted from an order. All

> the checkboxes share the same name, delItem. So when the form is 
> submitted and depending on the number of items I have selected to be

> deleted, what gets posted in the form should be an array of
delItems:
>
> [val1, val2, val3]
>
> So, in my flowscript which checks this value i do:
>
> var items = cocoon.request.get("delItem");
>
> var iterator = items.iterator();
>
> I then get an error message saying that iterator is not a function. 
> What am I doing wrong here?
>
> many thanks
>
> Andrew
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org 
> For additional commands, e-mail: users-help@cocoon.apache.org 
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org 
For additional commands, e-mail: users-help@cocoon.apache.org 


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message