Group all the textFields in an array

Hi guys, I need to perform some validation on the textFields used in an application, and I though, to check whether they’re all empty or not, I’d group them in an array and do it this way which seems rather fast. So, if I wanted to find the number of textFields used, how would I go about that? I checked the API but I couldn’t find any method like .length() for the textField. Any suggestion? Thanks

Hi,

have you considered using a FieldGroup? You could then add a Validator to your textFields that checks that they are not empty. See

https://vaadin.com/docs/-/part/framework/datamodel/datamodel-itembinding.html


https://vaadin.com/docs/-/part/framework/components/components-fields.html#components.fields.validation

for more info.

HTH,
Olli

hi thanks, I had no idea :-). I’ve found this though which is rather interesting, old, but interesting and it seems to work https://vaadin.com/forum#!/thread/2197093

If it works, it works :wink:

Have fun!

-Olli

No worries, thanks for your contribution though :-), I might use that if I get stuck with the solution I’ve found!
cheers