• Post Reply Bookmark Topic Watch Topic
  • New Topic

ManagedBean Injecting doesn't work (JSF / Primefaces)  RSS feed

 
Mikael Ghazarian
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I've been a JSF beginner. For my Project I used Primefaces.
I'm trying to get the data from a variable which is on a other managedbean.

The data of the managed bean is set by the selection from a datatable.
Actually it Returns null and I don't get it why.

I found a couple of examples in Google and did it like there but don't work.

View


myBean



User model



printUser


 
Tim Holloway
Bartender
Posts: 18715
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, for one thing, Rule #2 of JSF is "Request scope is almost completely useless in JSF". In particular, Request Scope is totally useless in dataTables, as the data gets destroyed as fast as you can use it.

Also, this is bad:


It should be:


You should not be calling things in EL code. EL is intended to define values and property references. The property reference for userList will cause JSF to automatically invoke the "getUserList" method on myBean.
 
Mikael Ghazarian
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Understanding!

Means It would work if I Change the Request scope to Session scope?
 
Tim Holloway
Bartender
Posts: 18715
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would work bettter, anyway. I didn't look closely enough to see if there are other issues (free support has its price).

View scope will work, too.
 
Uwe Lindenberg
Ranch Hand
Posts: 44
2
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mikael,

perhaps this is suitable for your requirements: ArrayDataModel<User>



and use it in a h:dataTable like this


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!