Artem
Artem

Reputation: 7423

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?

Upvotes: 1

Views: 1702

Answers (1)

martin-g
martin-g

Reputation: 17513

I think the following should do the job:

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

Upvotes: 2

Related Questions