Hi,
I have implemented pretty much the same functionality in our application.
U can do this using Struts actions.When the user presses a button,call an
action.In the action add an empty row to the form(add a empty object to the
list on form).And then call the same jsp which will just iterate over the list
as earlier.
//Pseudo code
Form MyForm{
List rowList = new ArrayList();
public Bean getBean(int index){
if(rowList.size < index){
rowList.add(new Bean());
}
return rowList.get(index);
}// getObject
public void setBean(int index,Bean obj){
rowList.setObject(index,obj);
}//setBean
//getter setter for list
public List getRowList (){
}
public void setRowList (List list){
}
}//MyForm
//JSP //
<table><tr>
<logic:iterate name="myForm" property="rowList" indexId="i">
<td><html:text name="myForm" property="<%=\"bean[\" + i +
\"].name\"%>"></td>
<td><html:text name="myForm" property="<%=\"bean[\" + i +
\"].location\"%>"></td>
</logic:iterate>
</tr><table>
So when the action is called, all the data on screen will be preserved as the
screen data gets repopulated in the form automatically.Then u add a new object
and the jsp cretes new table with a empty row.
Hope this helps.
Regards,
Shirish
-----Original Message-----
From: graham.cook [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 03, 2002 11:30 AM
To: struts-user
Subject: Design Issue in struts
Can I use struts to perform the following task:
generate a JSP page, but have multiple entry lines on the page. Im not going
to know how many lines the user is going to enter, so i'd like them to have
some kind of way ( maybe a button ) that the user can click on, the page
refreshes (retaining data) and shows a new blank line at the bottom of the
page under the other lines. When im talking lines I mean eg. Name, Location,
DOB, last contact
-----------------------------------------------
Security Code: 0162
Entry Date: 03/12/2002
Name Location DOB Last Contact
-------- ----------- ------
------------------
Fred Woking 07/12/1973 11/11/2002
Bert Wolverhampton 04/11/1976 11/11/2002
{Add}
{Submit} {Reset}
-------------------------------------------------
Then when the user presses SUBMIT the action is called and all data entered
into a database.
Has anyone got some real world example of this
Ta
********************************************************************************
************
" This message contains information that may be privileged or confidential and
is the property of the Cap Gemini Ernst & Young Group. It is intended only for
the person to whom it is addressed. If you are not the intended recipient, you
are not authorized to read, print, retain, copy, disseminate, distribute, or
use
this message or any part thereof. If you receive this message in error, please
notify the sender immediately and delete all copies of this message ".
********************************************************************************
************
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>