setting null value to all input components

Hi

I have list of components like textbox, list item etc in a layout. Is there a way to reset the item values to null in one go? the form has 50+ fields, setting the value to “null” for every item makes the code bad.

Thanks

Hey Saravanan,

do you use a FieldGroup? So set a new bean to the itemDataSource.

Sounds like a job for my
vQuery addon
. Sorry, not currently available in packaged form in the Directory :confused: Also, there’s currently no setValue method in FieldQuery because it’s often not very useful because Field is generic, but in this case it actually would. I’ll probably add it in a future version. Even without it, you can get quite clean code:

for(Field<?> field : VQuery.select(yourForm).descendants().isField()) {
    field.setValue(null);
}

Instead of VQuery.select, you can use a static import and the jQuery-like $ method.