opensubscriber
   Find in this group all groups
 
Unknown more information…

t : tapestry-user@jakarta.apache.org 5 May 2006 • 7:20PM -0400

PropertyselectionModel Q
by Peter Verhoye

REPLY TO AUTHOR
 
REPLY TO GROUP




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

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.