Aww, crap. I see it was already answered in a different thread….or something 
that showed up under a different thread in my mail reader at least. Sorry for 
the noise.  


On Monday, July 23, 2012 at 11:46 PM, David Hosier wrote:

> I think it's likely because your KeyValue class does not implement equals. 
> Your defaultValue has its own new instance of KeyValue that contains the key 
> JAVA and the value java. Your defaultValue instance and what you think is the 
> same instance in your list are not the same unless you correctly implement 
> equals() to identify them as the same. So you are telling the dropdown that 
> it should select something that it does not have in the list. Also, and this 
> may just be semantics, but it's probably inappropriate to call that thing a 
> default value since the dropdown will update the defaultValue value with 
> whatever you select in the dropdown (i.e. that defaultValue will only be the 
> default value until you change the selected value in the dropdown). So it's 
> probably more appropriately named selectedValue.  
>  
> -David  
>  
>  
> On Sunday, July 22, 2012 at 10:12 AM, vimal kumar wrote:
>  
> > Hi All,  
> > I have searched and wasted much of my time figuring out the default Value 
> > for DropDownChoice for Object as dropdown but couldn't find the solution. 
> > For "String" dropdown i was able to make it work but somehow for object it 
> > is not working.  
> > Below is the Simple example that i have been trying, 
> > DropDownChoicePage.html and DropDownChoicePage.java files.  
> > Can someone please help me that what am i missing into 
> > "DropDownChoicePage.java" class that is not setting the Drop Down Default 
> > value?  
> > ----------------------------------------  
> > DropDownChoicePage.html  
> > <html xmlns="http://www.w3.org/1999/xhtml";><head> <title>DropDown 
> > Example</title></head><body> Select your favorite Language <select 
> > wicket:id="languageDropDown"></select> </body></html>
> > ---------------------------------------------------------------  
> > DropDownChoicePage.java  
> > public class DropDownChoicePage extends WebPage {  
> > public class KeyValue {  
> > private String key; private String value;  
> > public KeyValue(String key, String value) { this.key = key; this.value = 
> > value; }  
> > public String getKey() { return key; }  
> > public String getValue() { return value; }  
> > public void setKey(String key) { this.key = key; }  
> > public void setValue(String value) { this.value = value; }  
> > @Override public String toString() { return getKey(); } }  
> > private static final long serialVersionUID = 2304448232406333188L;  
> > private KeyValue defaultValue = new KeyValue("JAVA", "Java");  
> > /** * Constructor */ public DropDownChoicePage() {  
> > List<KeyValue> keyValues = new ArrayList<DropDownChoicePage.KeyValue>(); 
> > keyValues.add(new KeyValue("PHP", "php")); keyValues.add(new 
> > KeyValue("JAVA", "Java")); keyValues.add(new KeyValue("DOT_NET", "Dot 
> > Net"));  
> > DropDownChoice<KeyValue> dropDownChoice = new DropDownChoice<KeyValue>( 
> > "languageDropDown", new PropertyModel<KeyValue>(this, "defaultValue"), 
> > keyValues, new ChoiceRenderer<KeyValue>("key", "value")); 
> > add(dropDownChoice);  
> > }  
> > public KeyValue getDefaultValue() { return defaultValue; }  
> > public void setDefaultValue(KeyValue defaultValue) { this.defaultValue = 
> > defaultValue; }  
> > }  
> > Thanks, Vimal.  
>  




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to