RE: How to fail validation if ListMultipleChoice is empty

2011-05-02 Thread Coleman, Chris
That was my plan exactly but I didn't know of a way to tell which button was doing the form submission until now! Thanks for that Form#findSubmittingButton works beautifully! I don't even think it's a hack as that validation should only really a problem if the user is submitting the form,

Re: How to fail validation if ListMultipleChoice is empty

2011-05-01 Thread Clint Checketts
Lets see the code about 'adding elements by pressing on a button'. The 'getValue()' method is returning the value from the list box's HTTP submitted values, if the add button is submitting values via ajax or some other means then it may need a different approach. -Clint On Sun, May 1, 2011 at

RE: How to fail validation if ListMultipleChoice is empty

2011-05-01 Thread Coleman, Chris
Yes, it's all via AJAX. In the last few minutes I've tried a different approach and it works ok but it introduces another problem: form.add(new AbstractFormValidator() { public FormComponent[] getDependentFormComponents() { return null; } public void validate(Form?

Re: How to fail validation if ListMultipleChoice is empty

2011-05-01 Thread Clint Checketts
You are correct that the Form's validation should only fire when submitting the form. When an individual element is updated via ajax (as in an AjaxFormComponentUpdatingBehavior) then just the processing and validations steps are fired for the individual form component. It makes me wonder if you

RE: How to fail validation if ListMultipleChoice is empty

2011-05-01 Thread Coleman, Chris
According to the doco the default form processing behavior is executed for AjaxButton and AjaxSubmitButton (in fact AjaxSubmitButton appears to be deprecated - behaves the same as AjaxButton anyway?). I am using AjaxButton. I actually don't care about the selections but rather, the entries

Re: How to fail validation if ListMultipleChoice is empty

2011-05-01 Thread Clint Checketts
Good catch on AjaxSubmitButton being deprecated, I guess an IDe would have made that obvious ;) I do have to say using the getChoices over a proper model may give you more work than needed in updating the underlying model objects (maybe consider overriding the getConvertedInput to return