File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Managedbean in managedbean null" Watch "Managedbean in managedbean null" New topic
Author

Managedbean in managedbean null

sreinaf rein
Greenhorn

Joined: Jul 06, 2013
Posts: 2
Hello,

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: 15641
    
  15

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.



Customer surveys are for companies who didn't pay proper attention to begin with.
sreinaf rein
Greenhorn

Joined: Jul 06, 2013
Posts: 2
Thank you!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Managedbean in managedbean null
 
Similar Threads
Problem injecting Sessionscoped bean in Managed bean
Problem with attributes backing bean
Doubt with Dependency Injection
@managedbean annotation doesn't work
JSF 2.0 - PropertyNotFoundException