-
1. Re: Getting the same managed bean in the same page
ctomc Dec 7, 2015 10:16 AM (in response to mvitorovic)my guess would be as you are mixing jsf and cdi injection and each one has its own lifecycle.
try using @javax.inject.Named("personUi") instead of @ManagedBean(name = "personUi")
and same for randomData class.
-
2. Re: Getting the same managed bean in the same page
mvitorovic Dec 8, 2015 2:10 AM (in response to ctomc)Thanks for your answer, but that didn't work. But during testing this approach a searched for a solution again, and this time I must have hit the correct search term, because I found the solution:
Injecting Managed beans in JSF 2.0
Works like a charm!
Thanks again, your answer put me on the right track.
Miha
-
3. Re: Getting the same managed bean in the same page
mvitorovic Dec 8, 2015 4:05 AM (in response to ctomc)Tomaz Cerar wrote:
my guess would be as you are mixing jsf and cdi injection and each one has its own lifecycle.
try using @javax.inject.Named("personUi") instead of @ManagedBean(name = "personUi")
and same for randomData class.
Also, I did managed to make it work as you suggested as well (previously I had my pom.xml misconfigured). After switching javaee-api to 7.0 this works as well:
import javax.faces.view.ViewScoped; import javax.inject.Named; @Named("randomData") @ViewScoped public class RandomData implements Serializable {
and
import javax.faces.view.ViewScoped; import javax.inject.Inject; import javax.inject.Named; @Named("personUi") @ViewScoped public class PersonUi implements Serializable { @Inject private RandomData randomData;
Thanks again, miha