Search code examples
javawicketwicket-1.6wicket-6

Wicket: How to use Map instead of PropertyModel?


We user Wicket 6 and usually are fine with POJO objects and PropertyModel to access model attributes. Now instead of a POJO I want to use a Map, how can I do that?

Instead of

form.add(new TextField<String>("fieldName", new PropertyModel<String>(pojo, "fieldName")));

I want to use something like

form.add(new TextField<String>("fieldName", new MapModel<String>(map, "field.name")));

Is there any Wicket class to do that?


Solution

  • I think the following should do the job:

    form.add(new TextField<String>("fieldName", new PropertyModel<String>(map, "keyName")));