You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Toby Hobson <to...@btinternet.com> on 2008/06/10 18:19:28 UTC
T5 Setting selected option on Select component
Hi
I have a page which allows a user to update his profile. This includes a select component to choose the user's state of residence:
public Enum State {
ALABAMA, ALASKA, ARIZONA ...
}
MyAccount.tml
// text fields etc.
<select t:type="select" t:id="state"
t:blankLabel="please select" t:blankOption="always"
t:value="user.state" name="select" id="select"
class="textbox_edit">
</select>
User.java
public class User {
private State state;
public State getState() {
return state;
}
public void setState(State state) {
this.state = state;
}
}
public class MyAccount {
private User user;
void onActivate() {
this.user = loadUser();
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
}
As you can see I load the user's profile in the onActivate() method. Doing this pre-populates the form with the user's details but I need to set the state to the user's current state. Currently all the fields are pre-populated except the select fields. How do I tell T5 to set a select field to the current value?
Thanks
Toby