File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes table with editable fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "table with editable fields" Watch "table with editable fields" New topic

table with editable fields

suni george

Joined: Apr 23, 2008
Posts: 2

I am trying to display a table which has editable fields and has the ability of adding new rows.

I am using <logic:iterate> to populate the input fields on the table. The ArrayList used is of type DataBean(another dto with 5 fields). My problem is that, i am not able to retrieve the data i enter on the screen as those fields are not directly related to the Form class for that form. Am i using a wrong approach or am i missing something. Please help.

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32822

Please check your private messages about an important administrative matter.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You will need to use "indexed properties" for this. For information on how to do this along with a simple example, see question 7 of this forum's FAQ.

Consultant, Sima Solutions
suni george

Joined: Apr 23, 2008
Posts: 2
Thanks for the reply. I tried using the indexed properties and i am not getting it to work. This is what i did:

1.Added into the struts config file form-property:
<form-bean name="enterDataForm" type = "mypkg.EnterDataForm">
<form-property name="sampleData" type="mypkg.dto.DataBean[]"/></form-bean>

2.Added in the jsp files the 'indexed=true' property

3.Added in the EnterDataForm class, new setter & getter: - sampleData is an Array of DataBean and has its regular setter and getter function too.

public DataBean getSampleData(int index)
return sampleData[index];

public void setSampleData(int index, DataBean b)

Is there something else i need to do?

[ April 24, 2008: Message edited by: suni george ]
[ April 24, 2008: Message edited by: suni george ]
I agree. Here's the link:
subject: table with editable fields
It's not a secret anymore!