Short mail:


       public EventDetailsStep() {

           setTitleModel(new ResourceModel("eventdetails.title"));
           setSummaryModel(new StringResourceModel("eventdetails.summary",
                   this, new Model<Event>(event)));

add(new RequiredTextField<String>("name").setLabel(new Model<String>("Eventname")));
           add(new TextArea<String>("description").setRequired(true));
           add(new DateField("date").setRequired(true));
add(new TextField<String>("location.name").setRequired(true).setLabel(new Model<String>("address")));
--------------------------------------------^^^^^^^^^^^^^^^
Nested property.

   public NewEventWizard(String id) {
       super(id);
       // create a blank event
       event = new Event();

       setDefaultModel(new CompoundPropertyModel<Event>(event));
       WizardModel model = new WizardModel();

This is working for me...



jensiator wrote:
Hi everyone
Time for a new question. This time its about the wizard component. I have
already done a couple of wizards and they work well. I have looked at the
example in wicket and of course I have changed it a little bit. I dont want
the steps do be static private classes so in my solution I send in the Model
that contains the BackingBean in the constructor of the wizardSteps. And it
works. Put in one case I Noticed that all the WizardSteps uses the same
backingbean, so I started to think about using a compoundpropertymodel that
I set to the Wizard in its constuctor. Something like this:
public MywizardConstuctor(String id){
   super(id);
   CompoundPropertyModel<BackingBean> formModel = new
CompoundPropertyModel<BackingBean>(new BackingBean());
    setDefaultModel(formModel);
    WizardModel wizardmodel = new WizardModel();
    wizardmodel.add(new WizardStep1());
    wizardmodel.add(new WizardStep2());
    init(wizardmodel);
}
Okey, in the WizardSteps constuctors I want to bind some TextFields to the
right property. Like this:
public WizardStep1(){
   TextField firstnameTF = new TextField<String>("firstName");
}
and it works well. BUT, this binding forces me to use the same markupid as
the backingbean property. Could be dangerous when different developers work
on the code. Someone might fail to notice this. I personly like when use the
propertmodel parameter in the TextField because it realy shows what your
doing. TextField firstnameTF = new TextField<String>("firstName",new
PropertyModel<String>(getDefaultModel(), "nestedobj.firstname"));
But I cant make it work! The former TextField code works, but the one with
getDeafultModel() doesnt. The defaultModel is null. I tryid to
findParent(Wizard.class).getDefaultModel() but it failes, probably because
the Step has not been added to the WizardModel yet.
Can anyone explain to me why 'new TextField<String>("firstName")' works?
Jens Alenius



--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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

Reply via email to