the post is pretty confusing, i dont really understand what it is
trying to solve/improve.

for an example of linked drop downs see [1], it is trivial to implement...

[1] http://wicketstuff.org/wicket13/ajax/choice

if on the other hand it is trying to render a map of key value pairs
as opposed to an object that contains key and value as properties that
is also trivial....

assuming

class DropDownChoice<T> { DropDownChoice(String,IModel<T>,
IModel<List<T>>, IChoiceRenderer<T> ....

you can create

class Pair<K,V> imlements Serializable { public K k; public V v; }

class KeyValueDropDownChoice<K,V> extends DropDownChoice<Pair<K,V>> {
  public KeyValueDropDownChoice(String id, IModel<K> model,
IModel<Map<K,V>> map) {
     super(id, model, new ChoicesModel(map), new ChoiceRenderer("k","v");
 }

   // make sure drop down choice uses K as model value instead of Pair
   @Override
    public String getModelValue()
    {
        final Object id = getModelObject();
        return (id==null) ? NO_SELECTION_VALUE : id.toString();
     }


   private static class ChoicesModel extends LoadableDetachableModel {
     private final IModel<Map<K,V>> mapModel;

      public Object load() {
        Map<K,V> map=mapModel.getObject();
        List<Pair<K,V>> choices=new ArrayList(map.size());
        for (Entry e:map.entryset()) {
            choices.add(new Pair(e.key, e.value));
         }
         return choices;
     }

    detach() { mapMode.detach(); super.detach(); }
}

looks like way less code to me for rendering key value pairs. but then
again, like i said, dont really understand what that blog is trying to
solve.

-igor


On Jan 1, 2008 11:24 PM, singhatulkr <[EMAIL PROTECTED]> wrote:
> I came across this blog today::
> http://donteattoomuch.blogspot.com/2007/12/playing-with-wicketthe-component.html
> It suggests some approach for drop-downs..
> ______________________________________
> Sent from my www.pageflakes.com startpage
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to