that is just what eelco means with implicit behaviour i guess.

javadoc:

Called when a null model is about to be retrieved in order to allow a subclass to provide an initial model....

So that initModel is only called when there is no model yet.
And the default behaviour is then the find a CompoundPropertyModel in one of its classes..
That is then to be used for its model (so a textfields gets the model of its form)

johan


Igor Vaynberg wrote:
The code in Component.initModel() looks like it only searches for models
that are instance of CompoundPropertyModel. Am I totally missing something?

Igor

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of Eelco
Hillenius
Sent: Tuesday, July 05, 2005 9:03 AM
To: [email protected]
Subject: Re: [Wicket-user] Newbie problem with Model-s

I'm afraid that is not true. I was kind of afraid people might think that;
it's one reason why I prefer explicit to implicit behaviour. The
CompoundPropertyModel is there for convenience really. It allows you to
'short hand' code that would otherwise by more verbose, and it is slightly
more efficient with object creation. But you can accomplish the same by just
using Model and PropertyModel objects.

Eelco

Igor Vaynberg wrote:

  
Martin,
The problem is here:
add(new TestForm("testForm", new Model(person)));

You are creating a Model, when in fact you should be creating a 
CompoundPropertyModel.
Components that do not have models ( ie your RequiredTextField ) only 
"inherit" models that are of type CompoundPropertyModel or derivatives 
there of.

To fix your example try
add(new TestForm("testForm", new CompoundPropertyModel(person)));

See the model wiki page for more explanations on models.
http://wicket.sourceforge.net/wiki/index.php/Models

Igor




-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of Martin 
Bednár
Sent: Tuesday, July 05, 2005 8:37 AM
To: [email protected]
Subject: [Wicket-user] Newbie problem with Model-s

Hi,
I have problems with updating models with data from page, I can't 
uderstand why it dosn't work :( Can anybody tell me what I'am doing wrong ?
There is my very simple sample.

package wicket.examples.my;
import java.io.Serializable;
import wicket.markup.html.WebPage;
import wicket.markup.html.form.Form;
import wicket.markup.html.form.RequiredTextField;
import wicket.model.IModel;
import wicket.model.Model;
import wicket.model.PropertyModel;

public class TestFieldPage extends WebPage {
   class Person implements Serializable {
       private String name = "TEST";

       public void setName(String name) {
           this.name = name;
       }

       public String getName() {
           return name;
       }
   }

   public TestFieldPage() {
       Person person = new Person();
       add(new TestForm("testForm", new Model(person)));
   }

   class TestForm extends Form {
       public TestForm(String id, IModel model) {
           super(id, model, null);
           add(new RequiredTextField("name", new PropertyModel(
                   model, "name")));
       }

       public void onFormSubmitted() {
           System.out.println(((Person) getModelObject()).getName());
       }
   }
}

with this markup:

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My Wicket Example</title>
</head>
<body>
<form wicket:id="testForm">
Name: <input type="text" wicket:id="name"/> </form> </body> </html>



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies 
    
>from IBM. Find simple to follow Roadmaps, straightforward articles, 
  
informative Webcasts and more! Get everything you need to get up to speed,
    
fast.
  
http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user






-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies 
    
>from IBM. Find simple to follow Roadmaps, straightforward articles, 
  
informative Webcasts and more! Get everything you need to get up to 
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user
 

    



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from
IBM. Find simple to follow Roadmaps, straightforward articles, informative
Webcasts and more! Get everything you need to get up to speed, fast.
http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user






-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

  

Reply via email to