You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by cy...@almacenes-paris.cl on 2004/05/07 19:11:20 UTC

Uploading list of items

Hi, I'm newbie with turbine and need to solve a problem.
I'm building a .vm, wich needs to ask the user for input a list of links, 
each one with a URL an a description (2 fields for each link). Furthermore 
the list needs to have a variable size, since the user could upload 1 or 
more links.

What is the best approach, using turbine, to implement this???

I've some experience doing this with struts, but it don't apply now...

Thank you very much.

Carlos.

RE: Uploading list of items

Posted by cy...@almacenes-paris.cl.
Thank you very much David!!




"David Demner" <tu...@demner.com> 
07-05-2004 16:26
Por favor, responda a
"Turbine Users List" <tu...@jakarta.apache.org>


Para
"'Turbine Users List'" <tu...@jakarta.apache.org>
cc

Asunto
RE: Uploading list of items






Hi Carlos,

What you would do is something like this in your action (assuming your 
boxes
are named url$i and desc$i as below):

for (int i = 1; i <=
data.getRequest().getParameter("CountUserEnteredInLastStep"); i++) {
  String url = data.getRequest().getParameter("url" + i);
  String desc = data.getRequest().getParameter("desc" + i);
  //maybe validate data better than this
  if (!url.equals("") && !desc.equals("")) {
    store(url, desc);
  }
}

So, because in the .vm file your text fields are named url$i and desc$i,
they are passed in the request parameters (by the form posting) as
url1/desc1, url2/desc2, urlN/descN, depending on the number of boxes the
user specified (hidden field CountUserEnteredInLastStep also passed via
request).  So you just access them from the request.

DAvid

-----Original Message-----
From: cyaconi@almacenes-paris.cl [mailto:cyaconi@almacenes-paris.cl] 
Sent: Friday May 7, 2004 12:53 PM
To: Turbine Users List
Subject: RE: Uploading list of items


Davis, actually I'm calling the event inside the action and I can get the 
single parameter values, my problem is how to parse the list of "link 
objects"... I mean, the list of url and descriptions...

Thank you!





---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org



RE: Uploading list of items

Posted by David Demner <tu...@demner.com>.
Hi Carlos,

What you would do is something like this in your action (assuming your boxes
are named url$i and desc$i as below):

for (int i = 1; i <=
data.getRequest().getParameter("CountUserEnteredInLastStep"); i++) {
  String url = data.getRequest().getParameter("url" + i);
  String desc = data.getRequest().getParameter("desc" + i);
  //maybe validate data better than this
  if (!url.equals("") && !desc.equals("")) {
    store(url, desc);
  }
}

So, because in the .vm file your text fields are named url$i and desc$i,
they are passed in the request parameters (by the form posting) as
url1/desc1, url2/desc2, urlN/descN, depending on the number of boxes the
user specified (hidden field CountUserEnteredInLastStep also passed via
request).  So you just access them from the request.

DAvid

-----Original Message-----
From: cyaconi@almacenes-paris.cl [mailto:cyaconi@almacenes-paris.cl] 
Sent: Friday May 7, 2004 12:53 PM
To: Turbine Users List
Subject: RE: Uploading list of items


Davis, actually I'm calling the event inside the action and I can get the 
single parameter values, my problem is how to parse the list of "link 
objects"... I mean, the list of url and descriptions...

Thank you!





---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Uploading list of items

Posted by cy...@almacenes-paris.cl.
Davis, actually I'm calling the event inside the action and I can get the 
single parameter values, my problem is how to parse the list of "link 
objects"... I mean, the list of url and descriptions...

Thank you!




"David Demner" <tu...@demner.com> 
07-05-2004 15:36
Por favor, responda a
"Turbine Users List" <tu...@jakarta.apache.org>


Para
"'Turbine Users List'" <tu...@jakarta.apache.org>
cc

Asunto
RE: Uploading list of items






Sure:

http://jakarta.apache.org/turbine/turbine-2.3/howto/index.html

The one you're probably looking for is the Action Events howto.  Short but
sweet.

Good luck,

DAvid

-----Original Message-----
From: cyaconi@almacenes-paris.cl [mailto:cyaconi@almacenes-paris.cl] 
Sent: Friday May 7, 2004 12:24 PM
To: Turbine Users List
Subject: RE: Uploading list of items


Thank you David... nice tip!
Do you know where I could find one of those howto's explaining how to 
implement the action class??






"David Demner" <tu...@demner.com> 
07-05-2004 13:47
Por favor, responda a
"Turbine Users List" <tu...@jakarta.apache.org>


Para
"'Turbine Users List'" <tu...@jakarta.apache.org>
cc

Asunto
RE: Uploading list of items






Hi Carlos,

Do you know the size beforehand (like prompting the user for the number of
links and then showing this number of boxes)?

If so, this is quite easy using a foreach loop.  Something like:


$count = $data.Parameters.CountUserEnteredInLastStep
#foreach (entry in [1..$count])
                 <!-- show the 2 boxes here, maybe with names url$i and 
desc$i -->
                 URL: <input type="text" size="12" name="url$i" value="" 
/>
                 Desc: <input type="text" size="12" name="desc$i" value="" 

/>
#end


You'd have a form that would send the data to an action and process the 
data
there (there are howtos on this).

If you want to add a new field each time the user starts typing in one
field, I'm not sure how you'd do it.

Good luck,

DAvid

-----Original Message-----
From: cyaconi@almacenes-paris.cl [mailto:cyaconi@almacenes-paris.cl] 
Sent: Friday May 7, 2004 10:11 AM
To: turbine-user@jakarta.apache.org
Subject: Uploading list of items


Hi, I'm newbie with turbine and need to solve a problem.
I'm building a .vm, wich needs to ask the user for input a list of links, 
each one with a URL an a description (2 fields for each link). Furthermore 


the list needs to have a variable size, since the user could upload 1 or 
more links.

What is the best approach, using turbine, to implement this???

I've some experience doing this with struts, but it don't apply now...

Thank you very much.

Carlos.


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org



RE: Uploading list of items

Posted by David Demner <tu...@demner.com>.
Sure:

http://jakarta.apache.org/turbine/turbine-2.3/howto/index.html

The one you're probably looking for is the Action Events howto.  Short but
sweet.

Good luck,

DAvid

-----Original Message-----
From: cyaconi@almacenes-paris.cl [mailto:cyaconi@almacenes-paris.cl] 
Sent: Friday May 7, 2004 12:24 PM
To: Turbine Users List
Subject: RE: Uploading list of items


Thank you David... nice tip!
Do you know where I could find one of those howto's explaining how to 
implement the action class??






"David Demner" <tu...@demner.com> 
07-05-2004 13:47
Por favor, responda a
"Turbine Users List" <tu...@jakarta.apache.org>


Para
"'Turbine Users List'" <tu...@jakarta.apache.org>
cc

Asunto
RE: Uploading list of items






Hi Carlos,

Do you know the size beforehand (like prompting the user for the number of
links and then showing this number of boxes)?

If so, this is quite easy using a foreach loop.  Something like:


$count = $data.Parameters.CountUserEnteredInLastStep
#foreach (entry in [1..$count])
                 <!-- show the 2 boxes here, maybe with names url$i and 
desc$i -->
                 URL: <input type="text" size="12" name="url$i" value="" 
/>
                 Desc: <input type="text" size="12" name="desc$i" value="" 
/>
#end


You'd have a form that would send the data to an action and process the 
data
there (there are howtos on this).

If you want to add a new field each time the user starts typing in one
field, I'm not sure how you'd do it.

Good luck,

DAvid

-----Original Message-----
From: cyaconi@almacenes-paris.cl [mailto:cyaconi@almacenes-paris.cl] 
Sent: Friday May 7, 2004 10:11 AM
To: turbine-user@jakarta.apache.org
Subject: Uploading list of items


Hi, I'm newbie with turbine and need to solve a problem.
I'm building a .vm, wich needs to ask the user for input a list of links, 
each one with a URL an a description (2 fields for each link). Furthermore 

the list needs to have a variable size, since the user could upload 1 or 
more links.

What is the best approach, using turbine, to implement this???

I've some experience doing this with struts, but it don't apply now...

Thank you very much.

Carlos.


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Uploading list of items

Posted by cy...@almacenes-paris.cl.
Thank you David... nice tip!
Do you know where I could find one of those howto's explaining how to 
implement the action class??






"David Demner" <tu...@demner.com> 
07-05-2004 13:47
Por favor, responda a
"Turbine Users List" <tu...@jakarta.apache.org>


Para
"'Turbine Users List'" <tu...@jakarta.apache.org>
cc

Asunto
RE: Uploading list of items






Hi Carlos,

Do you know the size beforehand (like prompting the user for the number of
links and then showing this number of boxes)?

If so, this is quite easy using a foreach loop.  Something like:


$count = $data.Parameters.CountUserEnteredInLastStep
#foreach (entry in [1..$count])
                 <!-- show the 2 boxes here, maybe with names url$i and 
desc$i -->
                 URL: <input type="text" size="12" name="url$i" value="" 
/>
                 Desc: <input type="text" size="12" name="desc$i" value="" 
/>
#end


You'd have a form that would send the data to an action and process the 
data
there (there are howtos on this).

If you want to add a new field each time the user starts typing in one
field, I'm not sure how you'd do it.

Good luck,

DAvid

-----Original Message-----
From: cyaconi@almacenes-paris.cl [mailto:cyaconi@almacenes-paris.cl] 
Sent: Friday May 7, 2004 10:11 AM
To: turbine-user@jakarta.apache.org
Subject: Uploading list of items


Hi, I'm newbie with turbine and need to solve a problem.
I'm building a .vm, wich needs to ask the user for input a list of links, 
each one with a URL an a description (2 fields for each link). Furthermore 

the list needs to have a variable size, since the user could upload 1 or 
more links.

What is the best approach, using turbine, to implement this???

I've some experience doing this with struts, but it don't apply now...

Thank you very much.

Carlos.


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org



RE: Uploading list of items

Posted by David Demner <tu...@demner.com>.
Hi Carlos,

Do you know the size beforehand (like prompting the user for the number of
links and then showing this number of boxes)?

If so, this is quite easy using a foreach loop.  Something like:


$count = $data.Parameters.CountUserEnteredInLastStep
#foreach (entry in [1..$count])
	<!-- show the 2 boxes here, maybe with names url$i and desc$i -->
	URL: <input type="text" size="12" name="url$i" value="" />
	Desc: <input type="text" size="12" name="desc$i" value="" />
#end


You'd have a form that would send the data to an action and process the data
there (there are howtos on this).

If you want to add a new field each time the user starts typing in one
field, I'm not sure how you'd do it.

Good luck,

DAvid

-----Original Message-----
From: cyaconi@almacenes-paris.cl [mailto:cyaconi@almacenes-paris.cl] 
Sent: Friday May 7, 2004 10:11 AM
To: turbine-user@jakarta.apache.org
Subject: Uploading list of items


Hi, I'm newbie with turbine and need to solve a problem.
I'm building a .vm, wich needs to ask the user for input a list of links, 
each one with a URL an a description (2 fields for each link). Furthermore 
the list needs to have a variable size, since the user could upload 1 or 
more links.

What is the best approach, using turbine, to implement this???

I've some experience doing this with struts, but it don't apply now...

Thank you very much.

Carlos.


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org