my dog learned polymorphism
The moose likes JSF and the fly likes Managedbean in managedbean null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Managedbean in managedbean null" Watch "Managedbean in managedbean null" New topic

Managedbean in managedbean null

sreinaf rein

Joined: Jul 06, 2013
Posts: 2

I'm a beginner in JSF and priemfaces.

I'm trying to inject a managed bean into an other one.

So i have a managed bean named generalInfo declared in face-config.xml

and the managed bean definition :

and the managedbean that will contain the generalInfo

declared in face-config.xml with view scope.

I can access generalInfo from xhtml pages but in ctrl class generalInfo is null

Where is the problem?
the setter and the getter of generalInfo are never called.

Thank's in advance!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

Welcome to the JavaRanch, Sreinhaf!

Well, for one thing "ctrl" is a very bad classname. There is a convention in Java that classnames start with an upper-case letter and that object instance and property names must start with a lower-case letter. Many tools will malfunction if you do not adhere to that standard.

Your sample code also does not include a package statement. If the actual code is also lacking the package statement, that places the class in question into the Java default package, which is also something that can cause you problems.

Finally, while your injected bean definition is OK, the injection target specifications are incomplete. So I cannot confirm that everything is properly done.

You are mixing XML (faces-config) and annotations. Be aware that XML will override annotations. It's best to use the same technique for everything to reduce confusion.

The following faces-config elements should function. Note that I have altered a few things to make them comply with JSF requirements. Actual details may vary.

An IDE is no substitute for an Intelligent Developer.
sreinaf rein

Joined: Jul 06, 2013
Posts: 2
Thank you!
I agree. Here's the link:
subject: Managedbean in managedbean null
It's not a secret anymore!