First, because a JSF backing bean's name should not begin with an upper-case letter. So "bmiData" would be a better choice, although if I'm not mistaken, if you'd left the name to the CDI/JSF bean definition factory default, it would define the name as "bMIdata" Yuck.
Secondaly, because an action isn't logic, It's a reference to a backing bean method. The page doesn't call that method, JSF does the calling. So a more acceptable format would be like this:
The BMI calculate method is invoked by JSF after JSF has validated all the control values on the submitted JSF form and, where applicable, converted them. So, for example, bmiData.data.birthdate would be a property of type java.Util.Date or a compatible datatype and JSF would update it via the data bean's "public void setBirthdate(Date newdate)" method.
Since an action method only fires IF and ONLY IF ALL form properties are valid, and since all form properties have been updated to the backing bean, the age calculation becomes trivial. Just have the action method use data.getBirthdate() to retrieve the entered value and use the date/time manipulation API to compute the difference between now and the entered birthdate.
When it comes to destroying a civilization, gas chambers cannot hold a candle to echo chambers.
posted 4 months ago
Thanks for the welcome and for the help ! Yeah... I translated it to english, the code is actually in portuguese and didn't realize that it was in upper. But about the rest, thanks, it helped me a lot !