You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Peter Verhoye <pe...@synergetic-solutions.be> on 2006/05/05 13:20:54 UTC

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: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org