Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

table with editable fields

 
suni george
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

Thanks,
sg.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sg",
Please check your private messages about an important administrative matter.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
suni george
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
{
sampleData[index]=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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic