You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Vlad Golodov <vl...@top.ee> on 2005/03/17 09:07:05 UTC

get an array from cocoon request

Hi!

was trying for a while to get an array from cocoon request in a JS flow. I
don't use CForms.

Such code is submitted:
<input type="checkbox" name="groups[]" value="1"/> group 1
<input type="checkbox" name="groups[]" value="2"/> Group 2
<input type="checkbox" name="groups[]" value="3"/> Group 3

In JS I was trying to get it in ways:
var groups = cocoon.request["groups"];
var groups = cocoon.request.groups;
var groups = cocoon.request.getParameter("groups");

Any ideas what could be wrong?

Thanks in advance,

Vlad




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


Re: get an array from cocoon request

Posted by Vlad Golodov <vl...@top.ee>.
Actually it should work without any index while submit. If we would use this
way: groups[1], then there wouldn't be the right order in an array.

Still fighting with the problem :S


"Geert Josten" <Ge...@daidalos.nl> wrote in message
news:423941C0.6010601@daidalos.nl...
> Hi all,
>
> This shouldn't be necessary. Input fields with same names are all
submitted and should be collected
> in the HTTP request as an array or something...
>
> Looking around on the web, I found a construct in XSP that might lead you
to what you need:
> xsp-request:get-parameter-values(name). You'll have to dig into the code
of the XSP generator (?) to
> find out how it is actually done...
>
> Cheers,
> Geert
>
> Mark Lowe wrote:
> > I'm not sure if something clever happens in cocoon but in a standard
> > case you'd want something like
> >
> > <input type="checkbox" name="groups[0]" value="1" />
> >
> > var value1 = cocoon.request.getParameter("groups[0]");
> >
> > multple select would perhaps behave more as you expect, but checkbox
> > is typically submiting a single value, any implemention of indexed
> > properties is done by whoever is doing the coding. groups[0] is a
> > string like anyother, just that by using the index its more scriptable
> > and readable then an alternative technique.
> >
> > You could iterate through the parameterNames to get the properties
> > that contain the string groups from the index of zero.
> >
> > Mark
> >
> >
> > On Thu, 17 Mar 2005 10:07:05 +0200, Vlad Golodov <vl...@top.ee> wrote:
> >
> >>Hi!
> >>
> >>was trying for a while to get an array from cocoon request in a JS flow.
I
> >>don't use CForms.
> >>
> >>Such code is submitted:
> >><input type="checkbox" name="groups[]" value="1"/> group 1
> >><input type="checkbox" name="groups[]" value="2"/> Group 2
> >><input type="checkbox" name="groups[]" value="3"/> Group 3
> >>
> >>In JS I was trying to get it in ways:
> >>var groups = cocoon.request["groups"];
> >>var groups = cocoon.request.groups;
> >>var groups = cocoon.request.getParameter("groups");
> >>
> >>Any ideas what could be wrong?
> >>
> >>Thanks in advance,
> >>
> >>Vlad
> >>
> >>---------------------------------------------------------------------
> >>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
> >
> >
> >
>
> -- 
> Geert.Josten@Daidalos.nl
> IT-consultant at Daidalos BV, Zoetermeer (NL)
>
> http://www.daidalos.nl/
> tel:+31-(0)79-3316961
> fax:+31-(0)79-3316464
>
> GPG: 1024D/12DEBB50




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


Re: get an array from cocoon request

Posted by Geert Josten <Ge...@daidalos.nl>.
Hi all,

This shouldn't be necessary. Input fields with same names are all submitted and should be collected 
in the HTTP request as an array or something...

Looking around on the web, I found a construct in XSP that might lead you to what you need: 
xsp-request:get-parameter-values(name). You'll have to dig into the code of the XSP generator (?) to 
find out how it is actually done...

Cheers,
Geert

Mark Lowe wrote:
> I'm not sure if something clever happens in cocoon but in a standard
> case you'd want something like
> 
> <input type="checkbox" name="groups[0]" value="1" />
> 
> var value1 = cocoon.request.getParameter("groups[0]");
> 
> multple select would perhaps behave more as you expect, but checkbox
> is typically submiting a single value, any implemention of indexed
> properties is done by whoever is doing the coding. groups[0] is a
> string like anyother, just that by using the index its more scriptable
> and readable then an alternative technique.
> 
> You could iterate through the parameterNames to get the properties
> that contain the string groups from the index of zero.
> 
> Mark
> 
> 
> On Thu, 17 Mar 2005 10:07:05 +0200, Vlad Golodov <vl...@top.ee> wrote:
> 
>>Hi!
>>
>>was trying for a while to get an array from cocoon request in a JS flow. I
>>don't use CForms.
>>
>>Such code is submitted:
>><input type="checkbox" name="groups[]" value="1"/> group 1
>><input type="checkbox" name="groups[]" value="2"/> Group 2
>><input type="checkbox" name="groups[]" value="3"/> Group 3
>>
>>In JS I was trying to get it in ways:
>>var groups = cocoon.request["groups"];
>>var groups = cocoon.request.groups;
>>var groups = cocoon.request.getParameter("groups");
>>
>>Any ideas what could be wrong?
>>
>>Thanks in advance,
>>
>>Vlad
>>
>>---------------------------------------------------------------------
>>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
> 
> 
> 

-- 
Geert.Josten@Daidalos.nl
IT-consultant at Daidalos BV, Zoetermeer (NL)

http://www.daidalos.nl/
tel:+31-(0)79-3316961
fax:+31-(0)79-3316464

GPG: 1024D/12DEBB50

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


Re: get an array from cocoon request

Posted by Mark Lowe <me...@gmail.com>.
I'm not sure if something clever happens in cocoon but in a standard
case you'd want something like

<input type="checkbox" name="groups[0]" value="1" />

var value1 = cocoon.request.getParameter("groups[0]");

multple select would perhaps behave more as you expect, but checkbox
is typically submiting a single value, any implemention of indexed
properties is done by whoever is doing the coding. groups[0] is a
string like anyother, just that by using the index its more scriptable
and readable then an alternative technique.

You could iterate through the parameterNames to get the properties
that contain the string groups from the index of zero.

Mark


On Thu, 17 Mar 2005 10:07:05 +0200, Vlad Golodov <vl...@top.ee> wrote:
> Hi!
> 
> was trying for a while to get an array from cocoon request in a JS flow. I
> don't use CForms.
> 
> Such code is submitted:
> <input type="checkbox" name="groups[]" value="1"/> group 1
> <input type="checkbox" name="groups[]" value="2"/> Group 2
> <input type="checkbox" name="groups[]" value="3"/> Group 3
> 
> In JS I was trying to get it in ways:
> var groups = cocoon.request["groups"];
> var groups = cocoon.request.groups;
> var groups = cocoon.request.getParameter("groups");
> 
> Any ideas what could be wrong?
> 
> Thanks in advance,
> 
> Vlad
> 
> ---------------------------------------------------------------------
> 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


[SOLVED] Re: get an array from cocoon request

Posted by Vlad Golodov <vl...@top.ee>.
Thanks all,

problem is solved by leaving brackets off
<input type="checkbox" name="groups" value="{groupId}"/> <xsl:value-of
select="groupName"/>

and collecting an array this way
var groups = cocoon.request.getParameterValues("groups");

Vlad

"Gertjan Assies" <ge...@assies.nu> wrote in message
news:42394CD7.6090901@assies.nu...
> I dont think the brackets should be in the name of the input element
> the request object takes the input elements with the same names and
> returns those as an array with the getParameter
>
> try
>
> <input type="checkbox" name="groups" value="1"/> group 1
>
> cheers,
> Gertjan
>
> Vlad Golodov wrote:
>
> >Hi!
> >
> >was trying for a while to get an array from cocoon request in a JS flow.
I
> >don't use CForms.
> >
> >Such code is submitted:
> ><input type="checkbox" name="groups[]" value="1"/> group 1
> ><input type="checkbox" name="groups[]" value="2"/> Group 2
> ><input type="checkbox" name="groups[]" value="3"/> Group 3
> >
> >In JS I was trying to get it in ways:
> >var groups = cocoon.request["groups"];
> >var groups = cocoon.request.groups;
> >var groups = cocoon.request.getParameter("groups");
> >
> >Any ideas what could be wrong?
> >
> >Thanks in advance,
> >
> >Vlad
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >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


Re: get an array from cocoon request

Posted by Gertjan Assies <ge...@assies.nu>.
I dont think the brackets should be in the name of the input element
the request object takes the input elements with the same names and 
returns those as an array with the getParameter

try

<input type="checkbox" name="groups" value="1"/> group 1

cheers,
Gertjan

Vlad Golodov wrote:

>Hi!
>
>was trying for a while to get an array from cocoon request in a JS flow. I
>don't use CForms.
>
>Such code is submitted:
><input type="checkbox" name="groups[]" value="1"/> group 1
><input type="checkbox" name="groups[]" value="2"/> Group 2
><input type="checkbox" name="groups[]" value="3"/> Group 3
>
>In JS I was trying to get it in ways:
>var groups = cocoon.request["groups"];
>var groups = cocoon.request.groups;
>var groups = cocoon.request.getParameter("groups");
>
>Any ideas what could be wrong?
>
>Thanks in advance,
>
>Vlad
>
>
>
>
>---------------------------------------------------------------------
>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


Re: get an array from cocoon request

Posted by Grzegorz TaƄczyk <go...@polzone.pl>.
Hello Vlad,

  Is there request.getParameterValues method in JS Flow? If no they
  You can try to make simple wrapper class in Java and connect it with
  Your JS Flow script :)

Thursday, March 17, 2005, 9:07:05 AM, you wrote:
VG> Hi!

VG> was trying for a while to get an array from cocoon request in a JS flow. I
VG> don't use CForms.

VG> Such code is submitted:
VG> <input type="checkbox" name="groups[]" value="1"/> group 1
VG> <input type="checkbox" name="groups[]" value="2"/> Group 2
VG> <input type="checkbox" name="groups[]" value="3"/> Group 3

VG> In JS I was trying to get it in ways:
VG> var groups = cocoon.request["groups"];
VG> var groups = cocoon.request.groups;
VG> var groups = cocoon.request.getParameter("groups");

VG> Any ideas what could be wrong?

VG> Thanks in advance,

VG> Vlad

-- 
Best regards,
 Grzegorz                            mailto:goliatus@polzone.pl


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