V
V
Vitaly Stolyarov2016-12-22 23:59:22
Play Framework
Vitaly Stolyarov, 2016-12-22 23:59:22

Why doesn't bindFromRequest find a field with a camelCase name?

These are the oddities that happened when parsing the request and converting it into a class object using bindFromRequest

public class Some {
public boolean isActive = false;
}

Form<Some> form = Form.form(Some.class).bindFromRequest();
Form.form().bindFromRequest().get("isActive");// OK, видит поле и оно true
form.isActive;// а вот это как было false, так и осталось

<input name="isActive" value="true" type="checkbox"> Is Active

If you change it to just "active", then everything works.
What then is the principle of bindFromRequest to parse and associate parameter names with fields? is_active as parameter with field name isActive in Some doesn't work either

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Stolyarov, 2016-12-23
@Ni55aN

After several errors of unknown origin, I discovered that bindFromRequest changes class data through setters, guided by the name of the method, not the object.
That is, if he received a request -> isActive, then he will look for the setIsActive method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question