Pregunta

I have a rather large implementation of a SmartGWT FilterBuilder, pretty similar to the Big Filter example in the SmartGWT showcase. The FilterBuilder uses a RestDataSource underneath to create it's fields via FormItems with operators and available values, some of which are pulled from the server and other's that are created by client-side data (i.e. a ComboBoxItem with options from a ValueMap). I currently make requests to the server based on the underlying criteria and that works just fine. Now, I want to prevent my query button from performing it's onclick handler when the values in the FormItems are invalid. I've been able to successfully add Validator's to some of the FormItems and DataSourceFields, and I can see in the GWT debugger that I am getting "invalid" returned from CustomValidator's condition, yet, when I call filterBuilder.validate() I always get back true (even with clearly invalid values in fields).

What gives? How can I validate on a FilterBuilder ?

¿Fue útil?

Solución

The FilterBuilder doesn't display validation errors inline (think about it - it's a very dense component and there's nowhere to stick the errors without it looking very odd).

Mostly you don't need to bother with validation when filtering. If someone types text into a numeric field there will be no results and this is self-explanatory. Validation is to avoid saving bad data into the database.

But if you have some unusual condition, the simplest thing is to return it as an error from the server and display it next to the filter interface or over the grid, inside an HTMLFlow for example.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top