Hi David,
Thanks for your prompt reply.
I am trying similar to your first suggestion. In your case, I
suppose, firstChoice has to be type String, but I made firstChoice as
type Course, where Course has several properties and one of them is
title. So I am trying to do similary to:
<h:selectOne id="firstChoice" value ="#{applicant.firstChoice.title}">
<f:selectItems value="#{school.availableCourses}"/>
</h:selectOne>
Basically, trying to bind value to #{applicant.firstChoice.title}
instead. Is it possible?
Thanks,
Damar
On 10/31/06, David Delbecq <[EMAIL PROTECTED]> wrote:
Hi,
Am a little confused by your explaination. I bet you are transforming a
textfield String (the course title) somehow in a Course object later.
I have 2 suggestions:
The first it to replace you textfield with a combo box, like this
<h:selectOne id="firstChoice" value ="#{applicant.firstChoice}">
<f:selectItems value="#{school.availableCourses}"/>
</h:selectOne>
with your school bean having something like this
public SelectItems[] getAvailableCourses(){
...
}
The second way to go is to use a converter
<h:inputText id="firstChoice" value ="#{applicant.firstChoice}">
<f:converter converterId="my.custom.Converter"/>
</h:inputText>
with the converter define in you faces-config.xml:
<converter>
<converter-id>my.custom.Converter</converter-id>
<converter-class>path.to.my.custom.CourseConverter</converter-class>
</converter>
your converter being an implementation of
javax.faces.convert.Converter
pointer: http://www-128.ibm.com/developerworks/java/library/j-jsf3/
Damar Thapa a écrit :
> Hi,
>
> I have following classes:
>
> Class Course(
> String title,
> String startDate.
> …..
> ….
>
> }
>
> and
>
> Class Apply{
>
> String studnetName;
> Course firstChoice;
> .....
> …….
> …..
> }
>
> In the apply form (page), I havae a field to accept course title from
> the applicant ie <h:inputText id="firstChoice"
> value="#{applicant.firstChoice.title}"/>. Since title is unique, I can
> retrieve Course object for firstChoice properties later before saving
> Apply object. But, I am getting ""firstChoice": Error during model
> data update." error on "#{applicant.firstChoice.title} . Can somebody
> on the list point me what am I missing?
>
> Any pointers would be highly appreciated.
>
> Thanks,
>
> Damar
>
--
With regards,
Damar Thapa