Hello smallufo:

> public class MyPanel extends Panel
> {
>   private MyObj myObj;
>
>   public MyPanel(String id , IModel model)
>   {
>     super(id);
>     this.myObj = (MyObj) model.getObject();
>
>     add(new Label("xxx" , myObj.getFieldX.toString()));
>     add(new Label("yyy" , myObj.getFieldY.toString()));
>
>   }
> }

This is the problem. Don't store the instance in the panel. Use the provided 
model. The Labels can get their data by a PropertyModel related to that 
model.
 public class MyPanel extends Panel
 {
  // removed while not required private MyObj myObj;

   public MyPanel(String id , IModel model)
   {
     super(id, model); <-- use this constructor
     // removed while not required this.myObj = (MyObj) model.getObject();

     // instead add(new Label("xxx" , myObj.getFieldX.toString()));
     add(new Label("xxx" , new PropertyModel(model, "fieldX")));
     // instead add(new Label("yyy" , myObj.getFieldY.toString()));
     add(new Label("yyy" , new PropertyModel(model, "fieldY")));
   }
 }

You simply wire the models together. So a model related to view can't be null 
(instanciated in panel self). That's what i mean if i always say "path to 
data". It's a description which properties have to be used to get the data. 
So the underlying business object can be null. The behavior if a null will be 
return will be determined by the component. A label for instance is 
displaying simply a blank. Textfield to.

HTH
Per

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

Reply via email to