Hi,
The DataProvider method is only called when the table needs the data, in
this case at render time. So the following should work:
public void onInit() {
table.setDataProvider(new DataProvider() {
public List<Customer> getData() {
if (form.isValid()) {
return getCustomerService().getCustomers();
} else {
return new ArrayList(); // <-- Return empty list
}
}
});
}
regards
Bob
On Thu, Feb 23, 2012 at 12:23 AM, Scott Gray <[email protected]> wrote:
> Total noob here but you could possibly try extracting your
> dataProvider logic into a separate method and then calling it from
> onGet() for defaults and from onSubmit() for the actual searches.
>
> Regards
> Scott
>
> On 23 February 2012 10:27, foxesout <[email protected]> wrote:
> > Thank you Gilberto, i actually looked through all the links you reference
> > before posting.
> > I believe I didn't formulated the question right...
> >
> > When the form is submitted, the onInit() method is executed first and
> then
> > the onSubmit() - or so I believe.
> > I set the dataProvider for the page in the onInit() method and pass the
> > request parameters to it.
> >
> > So what happens is - even if the form is invalid, the dataProvider is set
> > and the page will be rendered using invalid request parameters.
> >
> > What I'd like is to not render any data (just an empty table) if the form
> > doesn't validate.
> >
> > At the same time, when the page first loads, the data is being displayed
> > using the default parameters, so form submission is not necessary to
> display
> > data. That's why i can't set dataProvider in the onSubmit method.
> >
> > Thank you!
> >
> >
> > --
> > View this message in context:
> http://click.1134972.n2.nabble.com/How-to-not-bind-variables-when-the-form-is-invalid-tp7308872p7309878.html
> > Sent from the click-user mailing list archive at Nabble.com.
>