ManagedProperty « Bean « JSF Q&A

1. JSF - Set multiple values on @ManagedProperty in a single bean

I need to set 2 different ManagedProperty on the same bean. So i tried :

public class Selector {
    private String ...

2. @ManagedProperty(value = "#{}") in a non-request Scope Bean

I need to pass a parameter (POST) to a @managedBean, I used managed properties like this:

@ManagedProperty(value = "#{}")
private int id;
And the scope of the Bean is ViewScope I end up with this ...

3. ViewParam vs @ManagedProperty(value = "#{}")

What is the difference between defining View Params like this:

  <f:viewParam name="id" value="#{}"/>
And defining the property in the ManagedBean like this:
@ManagedProperty(value = "#{}")
private Integer id;
Thanks in advance

4. How to inject entire managed bean via @ManagedProperty annotation?

I'm trying to inject entire JSF managed bean into another managed bean by means of @ManagedProperty annotation (very similar to Possible to inject @ManagedBean as a @ManagedProperty into @WebServlet?, but ...

5. JSF 2 ManagedProperty injection of bean from dependency jar

I'm trying to get a ManagedProperty injection working, where the injected bean resides in a jar included in my web application. Bean to be injected:

public class Messages implements ...

6. Trouble using ManagedProperty

I'm trying to share an object between several SessionScoped beans. I get errors though and I really don't know why.

private testBean tb;
I believe that this is the right syntax, but any ...

7. @ManagedProperty - Inject one request scoped bean into another request scoped bean

I have this SearchBean:

@ManagedBean(name = "searchBean")
public class SearchBean implements Serializable
    private String input = null;

    // getter methods
    public String getInput() {

8. ManagedProperty not injected in @FacesConverter

I'm trying to inject a ManagedBean in my FacesConverted the following way:

@FacesConverter(forClass = Group.class)
public class GroupConverter implements Converter {

private GroupService groupService;

public Group getAsObject(FacesContext context, UIComponent arg1,

9. Retrieving updated value via @ManagedProperty / notifying other beans of updated value of a property

I have a SessionScoped bean say UserSession which holds a String property token which acts as a authenticated token for the logged in user. This token is injected into other SessionScoped ...

10. How to reference Java Collection entry from JSF 2 ManagedProperty?

I have an application that has a bean that holds a list of Contacts which are referenced from various domain objects throughout the application:

public class ContactHolder implements Serializable {

11. How to inject different subclasses as ManagedProperty JSF 2?

I'm new to JSF and I'm wondering if it's possible to inject different subclasses of a base class as a MangedProperty, depending on different situations? For instance, I have this managed ...

12. JSF2 Can't reach SessionScoped bean from ViewScoped as ManagedProperty

I have a strange problem. Afaik I can inject a SessionScoped bean into a viewscoped, because its broader, than the other. Here is my code:

public class ProjectBean implements Serializable {

private ProjectCurrentBean ...

13. Instantiate a ManagedBean (declared as @ManagedProperty) before using inside another ManagedBean

I am using a @ManagedBean(request scoped) as a @ManagedProperty inside another @ManagedBean. However the bean(one used as a @ManagedProperty) at the time of usage is un-instantiated and therefore leads to NullPointerException. ...

14. ViewScoped bean using ManagedProperty