You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Valery Jacot <vj...@eim.ch> on 2003/05/22 15:56:05 UTC

Problem to populate a form bean

Hello all, do somebody have already done something like that ?

I have this code:

I have to edit a list of StudentGrades object that are like that :

public StudentGrades {
   private String name, biology, chemistry, physics, english, math;

   public String getName () { return this.name; }
   public String getBiology () { return this.biology; }
   public String getChemisty () { return this.chemistry; }
   public String getPhysics () { return this.physics; }
   public String getEnglish () { return this.english; }
   public String getMath () { return this.math; }

   public void setName (String name) { this.name = name; }
   public void setBiology (String grade) { this.biology = grade; }
   public void setChemisty (String grade) { this.chemistry = grade; }
   public void setPhysics (String grade) { this.physics = grade; }
   public void setEnglish (String grade) { this.english = grade; }
   public void setMath (String grade) { this.math = grade; }
}

My form bean is like this:

public StudentGradeForm extends ActionForm{
  protected StudentGrades[] grades;
  public StudentGrades[] getGrades(){
	return this.grades;
  }
 
  public void setGrades(StudentGrades[] studentGrades){
	this.grades = studentGrades;
  }

	/*
		In the reset method, I initialize the <code>grades</code>
variable
		
		In the validate, I check this variable...
	/*
}


My jsp page looks like :

<html:form action="/some/action">
<TABLE>
	
<TR><TD>Name</TD><TD>Biology</TD><TD>Chemistry</TD><TD>Physics</TD><TD>Engli
sh</TD><TD>Math</TD></TR>
	<logic:iterate id="student" name="studentGradeForm"
property="grades" type="example.StudentGrades">
		<logic:notEmpty name="student" property="name">
			<TR>
			<TD><bean:write name="student" property="name"
indexed="true"/></TD>
			<TD><html:text name="student" property="biology"
indexed="true"/></TD>
			<TD><html:text name="student" property="chimstry"
indexed="true"/></TD>
			<TD><html:text name="student" property="physics"
indexed="true"/></TD>
			<TD><html:text name="student" property="english"
indexed="true"/></TD>
			<TD><html:text name="student" property="math"
indexed="true"/></TD></TR>
		</logic:notEmpty>
	</logic:iterate>
</TABLE>

I get the edition page correctly initialized, I edit some values and I
validate. The problem for me is to get the updated values, that means I can
see them in the parameters of the request but they are not correctly
populated by the BeanUtils...

So why ?

My form heritates from ActionForm, do I have to heritate it from
DynaActionForm ???

Thanks for your help

Valery


***********************************************************************************

This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager to postmaster@eim.ch

***********************************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org