I tried the code from that blog entry, but I don't think it will work. Or
maybe I'm wrong, but...

First, my understanding is that the code has two different types in the
model object and the choices object. In my case, the model object is a
string; and in any case the choices object will be an ArrayList<Map.Entry>.

Because of this, during render the ChoiceRenderer is called with different
types:

a) First, it is called with my model object (a string), from
AbstractSingleSelectChoice.getModelValue() 

        int index = getChoices().indexOf(object);
        return getChoiceRenderer().getIdValue(object, index);
        // calls getIdValue(String,int);

b) Later, it is called many times with the Map.Entry-object from
AbstractChoice.appendOptionHtml():

        T objectValue = (T)renderer.getDisplayValue(choice);
        // calls getDisplayValue(Map.Entry)

It seems to me that it is a fairly hard requirement that the model and the
choice list have identical types. I'll investigate a bit further, to see if
I can build a generic mechanism for both a Map and a "bean"-style object.



igor.vaynberg wrote:
> 
> http://steve-on-sakai.blogspot.com/2008/12/using-hashmap-with-dropdownchoice.html
> 
> -igor
> 
> On Wed, Aug 19, 2009 at 3:17 PM, Eirik Lygre<[email protected]> wrote:
>> I'm looking for the best way to implement a drop-down, where the type of
>> the
>> model property is not the type of the lists:
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/DropDown-where-%28type-of-model-property%29-%21%3D-%28type-of-choices%29-tp25052893p25058595.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]

Reply via email to