File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Issue when using ManagedProperty Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Issue when using ManagedProperty" Watch "Issue when using ManagedProperty" New topic

Issue when using ManagedProperty

Anu kuriakose

Joined: Mar 13, 2011
Posts: 6
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 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 will give me error then where shall i initialize these properties??? i cant give in my getter also.....what will i do???
Shasi Mitra
Ranch Hand

Joined: Nov 27, 2008
Posts: 101

Cant you have your group bean also as a managed bean configured in faces-config and have it instantiated by FacesServlet itself?
Anu kuriakose

Joined: Mar 13, 2011
Posts: 6
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 i cant use faces-Config
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Anu kuriakose 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.
Anu kuriakose

Joined: Mar 13, 2011
Posts: 6
Thanks for the reply...
I agree. Here's the link:
subject: Issue when using ManagedProperty
It's not a secret anymore!