J
jf
I have a Action Form that's generating multiple <html:text> box's by
using an ArrayList (property) of the form bean..
<html:form action="/jsp/UpdateRow">
<bean:define id="meuBean" name="EditRow"/>
<h3><bean:message key="EditRow.TableTitle.Name"/> <bean:write
name="meuBean" property="table"/></h3>
<html:text name="meuBean" property="table"/>
<table border=1>
<tr>
<logic:iterate id="col" name="meuBean" property="columns"
indexId="index">
<td><bean:write name="col" property="columnName"/></td>
<td>
<html:text name="col" property="value" indexed="true"/>
</td>
</tr>
</logic:iterate>
<tr>
<td>
<html:submit/>
</td>
The textbox's appear without any problems with the values. I made the
changes and i submit to the UpdateRow action (i am using the same
bean), but the arraylist (that i used to populate the text box's) is
not populated anymore, and worst: any change to the values are ignored.
It appears empty. I have implemented this on my form bean:
public class EditRow extends ActionForm {
private String table = "";
private String depends = "";
private String type= "";
private ArrayList columns = new ArrayList();
(...)
public Object getCol(int index)
{
if(index >= columns.size())
{ columns.add(index,new Object());
}
return columns.get(index);
}
public void setCol(int index, Object col)
{
if(index < columns.size())
{
columns.set(index,col);
}
else
{
columns.add(index,col);
}
}
/**
* @param columns The columns to set.
*/
public void setColumns(ArrayList columns) {
this.columns = columns;
}
/**
* @return Returns the depends.
.....
I know that using list backed property can solve this problem, but i
cannot figure how the hell (columns), the instance variable of my bean,
will be populated with the <html:text> from the JSP.
Thanks and i am very apreciated any help
JF (portugal)
using an ArrayList (property) of the form bean..
<html:form action="/jsp/UpdateRow">
<bean:define id="meuBean" name="EditRow"/>
<h3><bean:message key="EditRow.TableTitle.Name"/> <bean:write
name="meuBean" property="table"/></h3>
<html:text name="meuBean" property="table"/>
<table border=1>
<tr>
<logic:iterate id="col" name="meuBean" property="columns"
indexId="index">
<td><bean:write name="col" property="columnName"/></td>
<td>
<html:text name="col" property="value" indexed="true"/>
</td>
</tr>
</logic:iterate>
<tr>
<td>
<html:submit/>
</td>
The textbox's appear without any problems with the values. I made the
changes and i submit to the UpdateRow action (i am using the same
bean), but the arraylist (that i used to populate the text box's) is
not populated anymore, and worst: any change to the values are ignored.
It appears empty. I have implemented this on my form bean:
public class EditRow extends ActionForm {
private String table = "";
private String depends = "";
private String type= "";
private ArrayList columns = new ArrayList();
(...)
public Object getCol(int index)
{
if(index >= columns.size())
{ columns.add(index,new Object());
}
return columns.get(index);
}
public void setCol(int index, Object col)
{
if(index < columns.size())
{
columns.set(index,col);
}
else
{
columns.add(index,col);
}
}
/**
* @param columns The columns to set.
*/
public void setColumns(ArrayList columns) {
this.columns = columns;
}
/**
* @return Returns the depends.
.....
I know that using list backed property can solve this problem, but i
cannot figure how the hell (columns), the instance variable of my bean,
will be populated with the <html:text> from the JSP.
Thanks and i am very apreciated any help
JF (portugal)