Hi,

I've tried as you told be, but binding to the teacher's id does not work either.
It seems as if this part of the form was never populated, because neither the setter
of matTeacher nor the one of teacherId is ever called, as debugging through my application
told me.


Any further ideas / full struts example that provides a solution for the same problem?

Thanks in advance.

Kind regards,
  Simon


Rick Reumann wrote:
 > public class Student {
 >    ...
 >    private Teacher matTeacher;
 >    ...
 > }



Ah yes, I should have read your initial post longer. You definitely don't want to use an object for your property for the select. use the id of the matTeacher like I've shown and you should be all set.

Rick Reumann wrote the following on 4/4/2005 6:06 PM:

> Simon MARTIN wrote the following on 4/4/2005 5:37 PM:
>
>> In my JSP, I'm using this property like this:
>>
>> <html:select property="matTeacher" >
>> <c:set var="CURTEACHER" value="${student.matTeacher.teacherId}" />
>> <c:forEach var="teacher" items="${TEACHERMAT}" varStatus="status">
>> <option value="${teacher.teacherId}" <c:if test="${teacher.teacherId == CURTEACHER}">selected</c:if>>
>> <c:out value="${teacher.firstName}" /> <c:out value="${teacher.lastName}" />
>> </option>
>> </c:forEach>
>> </html:select>
>
>
>
> property="matTeacher". The property in your form "matTeacher" should be a number type (int, Integer, etc) or a String. Are you sure it's nott an Object of type Teacher? You probably want this...
>
> <html:select property="student.matTeacher.teacherId" >
> <c:forEach var="teacher" items="${TEACHERMAT}" varStatus="status">
> <option value="${teacher.teacherId}">
> <c:out value="${teacher.firstName}" /> <c:out value="${teacher.lastName}" />
> </option>
> </c:forEach>
> </html:select>
>
> You don't need the "if" test. If the id of property="student.matTeacher.teacherId" equals the teacherId, the tag takes care of setting this for you.
>
> My guess is your property for the select is wrong. You want some kind of "id" for that property that you can deal with.
>





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to