As in my earlier post i have to get my contacts from my addressbook bean to my groups bean to create groups of contacts. I do this using ManagedProperty....with this m able to retrive my contacts in my groups...my issue is i have to populate my fields from these contacts which i took as ManagedProperty.This has to be set only once when the page is initiated...i cant write it in my constructor...it will give me error then where shall i initialize these properties??? i cant give in my getter also.....what will i do???
Cant you have your group bean also as a managed bean configured in faces-config and have it instantiated by FacesServlet itself?
Joined: Mar 13, 2011
Yes both my beans are managedbeans......i am using @ManagedProperty for getting the values..what mu issue is that i have to call this page from a script and has to initialize...no i cant use faces-Config
Is this some sort of new idiotic management fad? Annotations can reduce or eliminate faces-config, but not all of the options that faces-config supports can be done via annotations. And in fact, I have a project of just such a type. It's one thing to mandate a standard, but quite another to hamstring people by taking tools out of the toolbox for arbitrary reasons.
JSF requires zero-argument constructors, so in order to inject properties, you have to use "setter" methods. However, to initialize data on only the first page view is a little trickier. But common. Besides, heavy-duty logic is not good practice in constructors and even worse practice in setters.
This question has come up before here, so I recommend searching the forum for a detailed discussion on how to do it. There were several threads on this topic, somewhere around a year ago.
An IDE is no substitute for an Intelligent Developer.