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

Reply via email to