Afaik no. Your right. I missed the "alidator" part of the interface IFormValidator. My explanation was related
the FromVisitor. Sorry for that.

But you could make palette final and access it inside the validate method.
Then you could do a palette.|getRecorderComponent().getSelectedChoices(). This method is accessing
the component values instead of the model values.

Hth (and sorry for my blindness)
Per
|
Does it means that Model of form is populated before Validate?
I didn't know that. In that way I also can use palette model in form and it
would have to work too.

Thanks for the solution!

Tito

2011/6/3 Per Newgro<per.new...@gmx.ch>

Sorry, i missed to say that you have to connect bunsinessModel and selected
list of palette.
Palette<Task>   palette = new Palette<Task>(..., new
PropertyModel<List<Task>>(model, "tasks"), ...);

Per

  Palette<Task>   palette = new Palette<Task>(.....);
form.add(palette);

form.add(new IFormValidator() {

     @Override
     public void Validate(Form<?>   form) {
           // how to get a list of selected tasks???
     }
});

You have to set the model to the form by assigning the list or wrap it in
a business model.
Then you can do a form.getModelObject() in validate method and cast it to
the assigned
list or business model.

Like this

public class MyBusinessModel {
  public List<Task>  getTasks() {
    ...
  }
}

public class MyComponent extends Panel {
  public MyComponent(String id, IModel<MyBusinessModel>  model) {
    super(id, model);
    Form<MyBusinessModel>  form = new Form("form", model);

  Palette<Task>   palette = new Palette<Task>(.....);
  form.add(palette);

  form.add(new IFormValidator() {

     @Override
     public void Validate(Form<?>   form) {
      MyBusinessModel model = (MyBusinessModel) form.getModelObject();
           // how to get a list of selected tasks???
      List<Task>   selectedTasks = model.getTasks();
     }
  });

  }
}


Hth
Per

I read that is a normal behavior. It's because validation occurs before
model population.
In that way when validation fails model won't be populated.

So I would have to do something like textField.getInput() but I had a
problem to get a model Object from a Palette.
For example:

Palette<Task>   palette = new Palette<Task>(.....);
form.add(palette);

form.add(new IFormValidator() {

      @Override
      public void Validate(Form<?>   form) {
            // how to get a list of selected tasks???
      }
});

So I made validation on "onSubmit" method of form. Now I'm fighting with
localized message to finish.

Thanks!
Tito

2011/5/31 Per Newgro<per.new...@gmx.ch>

  Am 31.05.2011 15:10, schrieb Tito:
  Is this ok?

I have to validate model object but it's detached when validate of form
validator is called. How can I make this validation?

Thanks

  Provide some code describing the problem please.

Cheers
Per

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Reply via email to