Question: I have started learning Wicket framework and I came across wicket models and I read about Model(), CompouneModel() and CompoundPropertyModel() but I didn't get the actual difference between them. I searched on Google for this, but I didn't get any information about this.

This [link](http://www.simplecodestuffs.com/difference-between-compound-model-and-propertymodel-in-wicket/) gives description between CompoundPropertyModel and PropertyModel but still its not clear properly for difference.

Only the thing I could distinguish between Model and other two is model can not work with dynamic fields while other two can.

Can someone please give the difference between these models?

Answer: 
All of them are implementations of the interface **IModel**.

Class **Model** is a basic implementation, that is almost just a 'data holder' so you can store an object in that model and get. The added value of this class is to forward to get and to set model object if the stored object is an other model (IModel).

Class **PropertyModel** is useful if you want to get / to set a property using property expression. See an example: 

```
class Data {

    private Integer data;
    private String name;

    /* getters and setters */

}

```

How to get and set data using the PropertyModel:

```
Data data = new Data();
data.setId(1);
data.setName("data entity");
IModel idModel = new PropertyModel(data, "id");
IModel nameModel = new PropertyModel(data, "name");

System.out.println(data.getId());
// prints '1'
System.out.println(idModel.getObject());
// prints '1'
System.out.println(data.getName);
// prints 'data entity'
System.out.println(nameModel.getObject());
// prints 'data entity'

data.setId(2);
nameModel.setObject("a new name");

System.out.println(data.getId());
// prints '2'
System.out.println(idModel.getObject());
// prints '2'
System.out.println(data.getName());
// prints 'a new name'
System.out.println(nameModel.getObject());
// prints 'a new name'

```

Class **CompoundPropertyModel** is useful if you want to propage properties to the components by their IDs. See an example (using the same class Data): 

*Java Code (MyPanel.java):*

```
class MyPanel extends Panel {

    public MyPanel(IModel<Data> model) {
        super(new CompoundPropertyModel<Data>(model));
        add(new Label("id"));
        add(new Label("data"));
    }
}

```

*Markup (MyPanel.html):*

```
<wicket:panel>
    <span wicket:id="id">placeholer for id</span>
    <span wicket:id="name">placeholer for id</span>
</wicket:panel>

```

*Java Code using MyClass:*

```
// in a Page, Panel or an other Component
Data data = new Data();
data.setId(3);
data.setName('my name');
add(new MyPanel(Model.of(data)));

```

Rendered output HTML (by the panel):

```
<span>3</span>
<span>my name</span>

```
Please check <https://cwiki.apache.org/confluence/display/WICKET/Working+with+Wicket+models>. It gives very good explanations.  

You can also read the official docs at <http://ci.apache.org/projects/wicket/guide/6.x/guide/modelsforms.html>