you should not need to do anything to see the current value in the box. Does your Language-class have a proper .equals() Method? May-be your DAO returns another Object-Instance when loading the language list than the one it put into the account-object when loading that.
> -----Original Message----- > From: Peter Verhoye [mailto:[EMAIL PROTECTED] > Sent: Friday, May 05, 2006 1:21 PM > To: Tapestry users > Subject: PropertyselectionModel Q > > > Hi all, > > I'm trying to do the following: > > We have an object (Account) which contains an other object (Language). > To edit the account, I've created an accountEdit page where I want to > have a dropdown box that shows the list of languages one can > set for an > account. But, I want the list to be set to the language the account > already has if available. > So, I've already created the following: > > public class LanguageSelectionModel implements > IPropertySelectionModel, > Serializable { > private static final long serialVersionUID = > -3912209045599735086L; > > private List<Language> languageList; > > private String languageId; > > public LanguageSelectionModel(List<Language> > languageList, String > languageId) { > this.languageList = languageList; > this.languageId = languageId; > } > > public int getOptionCount() { > return languageList.size(); > } > > public Object getOption(int index) { > return languageList.get(index); > } > > public String getLabel(int index) { > return > languageList.get(index).getDescription(languageId); > } > > public String getValue(int index) { > return Integer.toString(index); > } > > public Object translateValue(String value) { > return getOption(Integer.parseInt(value)); > } > } > > In the AccountEdit.page file I have this: > <component id="language" type="PropertySelection"> > <binding name="model" value="availableLanguages"/> > <binding name="value" value="account.language"/> > </component> > > > In the AccountEdit.java file I have the following: > public IPropertySelectionModel getAvailableLanguages() { > String languageId = > getVisitObject().getContactPerson().getLanguage().getId(); > return new > LanguageSelectionModel(getLanguageDAO().findLanguages(), > languageId); > } > > Now, this all seems to work except that the combobox does not get > initialised on the correct Language object. Now, I think I > know why but > I don't know how I should initialise the PropertySelectionModel. > > Anyway has an idea or so? > > Thank you!! > > BB > Peter > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]