Hello Guys, I have a problem with my nested tag page. I like to create a dynamic form, the creation itself is not a problem. The form is presented as it should be and although the preallocation works well. The problem is that the values set by the user are not stored in the form bean when the form is submitted. Instead of that, a new form is created and given to the action. Does someone know a reason for that or where my mistake may be? Or does someone has a hint where I my find information to that? I have several books here (programming Jarkarta Struts,...) and know the keyboardmonkey tutorial. Thanks a lot
thx Velligis
Code:
public class ErfassungForm extends ActionForm implements Serializable{
private ArrayList erfassung; //
/** Creates a new instance of ErfassungForm */
public ErfassungForm(){
super();
};
public void reset(ActionMapping mapping, HttpServletRequest request) {
resetFields();
//Get the data out of the request and preallocate the form
ErfassungView[] pErfassung = (ErfassungView[])request.getAttribute("erfassung");
if(pErfassung!=null){
this.setFields(pErfassung);
}
}
protected void resetFields() {
erfassung=null;
}
public void setErfassung(int x, ErfassungView pErfassung){
erfassung.set(x, pErfassung);
}
public ErfassungView getErfassung(int x){
while(x>=erfassung.size()){
erfassung.add(new ErfassungView());
}
return (ErfassungView)erfassung.get(x);
}
public Object[] getErfassung(){
return this.erfassung.toArray();
}
/**Preallocation*/
private void setFields(ErfassungView[] pErfassung) {
if (pErfassung!=null){
this.erfassung = new ArrayList();
for(int i=0; i< pErfassung.length; i++) {
erfassung.add(pErfassung[i]);
}
}
}
}
The JSP:
<html:form action="antwortAction.do" method="post">
<nested:iterate id="daten" name="erfassung" indexId="x" type="view.ErfassungView">
<table cellpadding="0" cellspacing="0" class="rand" width="610px">
<tr class="head">
<td width="305"><span title="<bean:write name="daten" property="frage.hilfe" />">
<bean:write name="daten" property="frage.text"/></span>
</td>
<td class="right">
<bean:message key="label.ja"/>
<nested:checkbox name="daten" property="antwort.ja"/> |
<bean:message key="label.nein"/>
<nested:checkbox name="daten" property="antwort.nein"/>
<logic:equal name="daten" property="frage.pflicht" value="false">
|
<bean:message key="label.essa.nichtRelevant"/>
<nested:checkbox name="daten" property="antwort.nichtRelevant"/>
</logic:equal>
</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="2"><bean:message key="label.essa.problem"/>:</td>
</tr>
<tr>
<td colspan="2"><nested:textarea name="daten" property="antwort.antwort" cols="72" rows="5"/></td>
</tr>
<tr>
<td><bean:message key="label.essa.person"/>:</td>
<td><bean:message key="label.essa.bis_wann"/>:</td>
</tr>
<tr>
<td width="305"><nested:text name="daten" property="antwort.verantwortlicher" size="45"/></td>
<td width="305"><nested:text name="daten" property="antwort.bisWann" size="45"/></td>
</tr>
<tr>
<td>
<nested:checkbox name="daten" property="antwort.erledigt"/>
<bean:message key="label.essa.erledigt"/>?
</td>
<td class="right">
<a href="<bean:write name="daten" property="frage.link" />" title="<bean:write name="daten" property="frage.hilfe" />">
<bean:message key="label.hilfe"/></a>
</td>
</tr>
</table>
</nested:iterate>
</td>
</tr>
<tr class="l_padding">
<td><br/><html:submit><bean:message key="button.speichern"/></html:submit>
<br/><%@include file="includes/zeig_fehler.jsp"%>
</td>
</tr>
</html:form>
thx Velligis