Binder in Form, in case only to take all data in form to a bean, do i need it?

hi,

I need inputs or some thoughts regarding Binder.

Binder will bind a bean with values in a form.

Question is do i need a binder to a bean if:

  1. I only need to take form values to a bean.
  2. I need some default behaviours in form such as:
    2.1 Combo box group will be none is selected at the beginning of view.
    2.2 Date picker will be empty at the beginning of view.
  3. I need bean validation for user inputs if button pressed.

Thank you for all you hints.
sLawalata

Do you need binder to do all those things? No
Would binder make it easier? yes!

Hi @knoobie, thanks for your replay.

For taking all values from a form what i need to do:

  1. Create an empty bean.
  2. Bind this bean with a form.
    I find that i need to set all default values for this form. For example a birthday, i need to bind setter and getter and give a default value a localdate in the bean. If not binder will complain that it try to set a null value from bean to form.
    Meanwhile i don’t need to set all default values in form because all this value must be empty as default in a form if i dont use binder.

Question is all default value should be set if we want to use binder?
Or even it is a best practice to set all default value in a form?

Thank you,
sLawalata

What do you mean with default values? null is a default value, so there is nothing to be set. If you want to use e.g. 1980-01-01 as default value because it was e.g. preselected in the bean; add this field / attribute to your bean and let the binder read it.