Ketan Bhavsar
Ketan Bhavsar

Reputation: 5396

JSF put context back after modify it

I am using this to access context of backing bean from another backing bean.

I am modifying property of this bean in current one. Can I put this context back?

TemplatePrescriptionMaintenanceBackingBean templatePrescBean = (TemplatePrescriptionMaintenanceBackingBean)context.getApplication()
            .evaluateExpressionGet(context, "#{templatePrescriptionMaintenanceBackingBean}", TemplatePrescriptionMaintenanceBackingBean.class);

Upvotes: 0

Views: 77

Answers (1)

BalusC
BalusC

Reputation: 1108922

That's not necessary. You're obtaining a reference to an existing bean instance, not a copy or something. If you manipulate the reference, then it'll be "reflected" anywhere else which is also holding a reference to this instance. Java is an OO language, not a procedural language or something.

By the way, @ManagedProperty is a better approach to obtain a reference to another managed bean.

See also:

Upvotes: 1

Related Questions