Birth Date nightmare - passing variable between beans and java objects
posted 6 years ago
I'm writing my first JSF application.
I have a problem with passing date onto "person" bean.
i have 3 beans:
person - scope: session
personManager - scope: application - holds the list of persons
dateOfBirth - scope: session - holds 3 ints from the drop down menu like select created by <h:selectOneMenu> for day, month and year and have method which creates a Date object from those 3 ints
In faces-config.xml i've added the dependency for person so the dateOfBirth.date was injected into person.dob (well actually eclipse did it for me through a wizard)
Everything would be great without the fact that person.dob is always 31.12.1899 00:00:00 and not the one i've selected in the form
So the thing is i must use <h:selectOneMenu> to select DOB. I can put there a <h:inputText> (which i did and it was working using datetime converter) but that was just for testing and now i must use 3 selects which generates an Date object for person bean whis will then be stored inside the personManager bean in a list.
The thing is as i said it before, the date is always the same. If i hardcode in DateOfBirth int year = 10; then it will stay as 10 (1910).
I also did a simple jsp page to check the variables for dateOfBirth bean
and when i refresh this page i can see the variables have changed correctly so the thing is that p.setDob(dob) in person.addPerson() gets wrong Date object which is provided by dependency injection from jsf.
So finally how can i fix my problem ?
The best answer would be instructions: change this to that in here and so on...
I'm now after 48h without sleep and i'm trying to get past this problem.