1
votes

I'm using a property inside one bean as a Managed Property inside another.

The problem I'm facing is with change of the property inside the source bean, the target bean's Managed Property is NOT getting updated. If Java uses referencing instead of creating new object in the memory, this shouldn't be happening, but it is.

Both my beans are session-scoped. Does that affect the injection of the property? Does that mean change in view does NOT initialize the injection if the beans are session-scoped? Even then, it goes against the referencing idea user BalusC has made in the comment of this answer.

How to get managedbean property from another bean in JSF

1

1 Answers

1
votes

Apparently you're referencing the target bean's property directly instead of the target bean itself.

The below is indeed wrong:

@ManagedProperty("#{otherBean.property}")
private String otherBeanProperty;

String is immutable and you're basically copying the property. This isn't mutable by reference.

Instead you should be doing:

@ManagedProperty("#{otherBean}")
private OtherBean otherBean;

and then obtain the desired property by its getter in any of the source bean's methods.