You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by JOEL VOGT <jo...@studentmail.newcastle.edu.au> on 2001/03/23 07:13:24 UTC

how do I do this in struts?

Hi all,

I have the following situation.
I have a jsp page with a large table. This table is filled using the
logic iterate tag. I get the data from a bean and this works fine. In 
my structures, every row represents a data item from the bean.
Now, apart from displaying the data, on each row I have two fields from 
which I need input.
One of these is a textbox, the other a checkbox.
How do I get the input from the user, and get it to update my bean with 
the relevant details? They must input the data in the relevent table 
row, and then i want this data to go into the required item in the bean.

I hope this isn't too confusing. If anyone can help, that would be 
great.

Thanks, Joel.


Re: how do I do this in struts?

Posted by Ken Beyer <ka...@metatec.com>.
JOEL VOGT wrote:

> Hi all,
>
> I have the following situation.
> I have a jsp page with a large table. This table is filled using the
> logic iterate tag. I get the data from a bean and this works fine. In
> my structures, every row represents a data item from the bean.
> Now, apart from displaying the data, on each row I have two fields from
> which I need input.
> One of these is a textbox, the other a checkbox.
> How do I get the input from the user, and get it to update my bean with
> the relevant details? They must input the data in the relevent table
> row, and then i want this data to go into the required item in the bean.

there might be other ways to do this, but here's 3...

option1:
If you want one submit button (i.e. 1 form being posted), you'll
need to identify your text and checkbox fields with the row ID you're
iterating over (i.e. chkbox.rowid.243) and have your controlling servlet
(i.e. processform.do) walk through getParameterNames() and process
them (update your database) accordingly.

option2:
If you can have multiple submit buttons (but this hit's the server more),
then you can use a hidden field to track the rowid your text and checkbox
are associated with.  Have your processform.do handle the businesslogic,
and then forward to the same page to show the results.

option3:
Have a hyperlink (like in the Struts example) take you to the specific
row details (i.e. don't put the text and checkbox on the same page you iterate over).
Then on that detail page you put your text and checkbox.  Here also
a hidden field would hold your row ID.  This could submit to processform.do
and forward to the iterate page.

you might also be able to do something fancy w/ javascript.

hope that helps,
Ken

>
>
> I hope this isn't too confusing. If anyone can help, that would be
> great.
>
> Thanks, Joel.

--
Ken Beyer
Metatec Internet Products Group
kab@metatec.com  |  http://www.metatec.com/
"The box said 'Requires Windows 95 or better.' - so I installed Linux."




Re: how do I do this in struts?

Posted by Ted Husted <hu...@apache.org>.
The only way to get input from a user in a Web application is with a
form. If they only need to update one row at a time, then each row could
be a form, and the fields associated with a Struts ActionForm bean.

But, I think you want them to update any number of rows at a time. 

The only thing that occurs to me is that this is a job for the new
RowSet API. 

< http://developer.java.sun.com/developer/earlyAccess/crs/ >

But, offhand, I don't know how you would edit a RowSet in a conventional
Web application. 

If this were an option, an applet that updated a RowSet would be a good
way to go.

JOEL VOGT wrote:
> 
> Hi all,
> 
> I have the following situation.
> I have a jsp page with a large table. This table is filled using the
> logic iterate tag. I get the data from a bean and this works fine. In
> my structures, every row represents a data item from the bean.
> Now, apart from displaying the data, on each row I have two fields from
> which I need input.
> One of these is a textbox, the other a checkbox.
> How do I get the input from the user, and get it to update my bean with
> the relevant details? They must input the data in the relevent table
> row, and then i want this data to go into the required item in the bean.
> 
> I hope this isn't too confusing. If anyone can help, that would be
> great.
> 
> Thanks, Joel.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/