• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Managedbean in managedbean null

 
sreinaf rein
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
sreinaf rein
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic