sorry dudu, i am new to wicket as well, have you came across this link yet? http://cwiki.apache.org/WICKET/dropdownchoice-examples.html
if not give it a shot Mathias P.W Nilsson wrote: > > <html> > <head> > <title>Wicket Quickstart Archetype Homepage</title> > </head> > <body> > > <form wicket:id="loginForm"> > > <strong>Wicket Quickstart Archetype Homepage</strong> > <br/><br/> > message will be here > > <select wicket:id="category" name="category"> > <option>Some Person</option> > <option>Some Other Person</option> > </select> > > <input type="submit" wicket:id="Submit"> > </form> > </body> > </html> > > > =================================== > CODE > =================================== > package se.boardstore.model; > > import java.io.Serializable; > import java.util.ArrayList; > import java.util.List; > > import se.boardstore.entities.store.Store; > > public class Category implements Serializable{ > > private Long id; > private String identifier; > private Long sortOrder; > private String name; > private String shortDescription; > private String longDescription; > private Store store; > private Long cachedBalance; > private List<Category> categories = new ArrayList<Category>(); > > public Category(){ > > } > > public String getIdentifier() { > return identifier; > } > > public void setIdentifier(String identifier) { > this.identifier = identifier; > } > > public Long getSortOrder() { > return sortOrder; > } > > public void setSortOrder(Long sortOrder) { > this.sortOrder = sortOrder; > } > > public Long getId() { > return id; > } > > public String toString(){ > StringBuffer buffer = new StringBuffer(); > buffer.append( "[Id: " + id + "]" ); > buffer.append( "[Identifier: " + identifier + "]" ); > buffer.append( "[Sortorder: " + sortOrder + "]" ); > > return buffer.toString(); > } > > > public String getName() { > return name; > } > > > public void setName(String name) { > this.name = name; > } > > > public String getShortDescription() { > return shortDescription; > } > > > public void setShortDescription(String shortDescription) { > this.shortDescription = shortDescription; > } > > > public String getLongDescription() { > return longDescription; > } > > > public void setLongDescription(String longDescription) { > this.longDescription = longDescription; > } > > > public Store getStore() { > return store; > } > > > public void setStore(Store store) { > this.store = store; > } > > > public List<Category> getCategories() { > return categories; > } > > > public void setId(Long id) { > this.id = id; > } > > public Long getCachedBalance() { > return cachedBalance; > } > > public void setCachedBalance(Long cachedBalance) { > this.cachedBalance = cachedBalance; > } > > public void addCategory( Category category ){ > this.categories.add( category ); > } > > } > > > ============================================ > CODE > ============================================= > > > package se.edgesoft; > > import java.io.Serializable; > import java.util.List; > > import org.apache.wicket.PageParameters; > import org.apache.wicket.extensions.markup.html.form.select.SelectOption; > import org.apache.wicket.markup.html.WebPage; > import org.apache.wicket.markup.html.basic.Label; > import org.apache.wicket.markup.html.form.Button; > import org.apache.wicket.markup.html.form.DropDownChoice; > import org.apache.wicket.markup.html.form.Form; > import org.apache.wicket.markup.html.form.IChoiceRenderer; > import org.apache.wicket.markup.html.list.ListItem; > import org.apache.wicket.markup.html.list.ListView; > import org.apache.wicket.model.LoadableDetachableModel; > import org.apache.wicket.model.PropertyModel; > import org.apache.wicket.spring.injection.annot.SpringBean; > > import se.boardstore.dao.CategoryDAO; > > > /** > * Homepage > */ > public class HomePage extends WebPage { > > private static final long serialVersionUID = 1L; > @SpringBean(name="categoryDao") > private CategoryDAO categoryDAO; > List<se.boardstore.model.Category> categories; > public HomePage(final PageParameters parameters) { > > Form form = new LoginForm( "loginForm" ); > add(form); > > form.add(new Label("message", "If you see this message wicket is > properly configured and running")); > > categories = > categoryDAO.getProxiedCategories(se.boardstore.entities.store.Store.EDDYEMERY_EU); > > DropDownChoice ddc = > new DropDownChoice( > "category", > new PropertyModel( new se.boardstore.model.Category(), > "name"), > new LoadableDetachableModel() { > private static final long > serialVersionUID = 1L; > > @Override > protected Object load() { > return HomePage.this.categories; > } > > > },new TestChoiceRenderer() > ){ > private static final long > serialVersionUID = 1L; > > protected boolean wantOnSelectionChangedNotifications() > { > return true; > } > > /** > * Called when a option is selected of a dropdown list that > wants to be > * notified of this event. > * > * @param newSelection The newly selected object of the > backing model > */ > protected void onSelectionChanged(Object newSelection) { > > System.out.println( newSelection.getClass() ); > > //se.boardstore.model.Category category = > (se.boardstore.model.Category) newSelection; > //System.out.println( category.getName() ); > } > }; > > form.add( ddc ); > > > > Button submit = new Button( "Submit" ); > form.add( submit ); > > > } > > class LoginForm extends Form{ > > public LoginForm( String identifier ){ > super( identifier ); > } > > public void onSubmit(){ > System.out.println( "JEpp" ); > AutoCompletePage p = new AutoCompletePage( new > PageParameters()); > setResponsePage( p ); > } > } > > class TestChoiceRenderer implements IChoiceRenderer { > > public Object getDisplayValue(Object object) { > // I don't know if it can be anything other...?? > if (object instanceof se.boardstore.model.Category) { > se.boardstore.model.Category so = > (se.boardstore.model.Category) object; > > > return so.getName(); > } > return null; > } > > public String getIdValue(Object key, int index) { > // I don't know if it can be anything other...?? > if (key instanceof se.boardstore.model.Category) { > se.boardstore.model.Category selectOption = > (se.boardstore.model.Category) key; > return selectOption.getId().toString(); > > } > return null; > } > > } > > } > > -- View this message in context: http://www.nabble.com/DropDownChoice-problem-tp15095051p15097014.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]