The blog for hints & tips about Oracle Application Development Framework and Mobile Application Framework

Managing component value state correctly

Frank Nimphius
Master Principal Product Manager

A frequent problem reported on OTN is about failure in
saving component values using managed beans especially when multi-select components are used.
Usually the problem arises when developers store select choice components values in managed beans they use for JSF component bindings as well (which then makes the managed bean becoming a backing bean). Backing beans however are saved in request scope (at least they should to not err again).

Request scope beans however reset their state after each
request, which means that no user update in a select component is
persisted beyond the request. The result is that user changes are not displayed in the UI or value change listeners don't execute.The proper way of handling the combination of backing beans and
component values saved in a managed bean is to come up with a strategy in which
the component value is written to a separate bean in a broader scope (I usually
recommend viewScope) than the backing bean. The backing bean (request scope)
would then access the bean in the larger scope using a ValueExpression or managed bean
property to access the user selected data.

I was about to write this solution up in more detail but
then found the following blog entry by Duncan Mills:


In his The UIManager
blog entry, Duncan documented the same problem from a different
angle. The programmer mistake Duncan observed was that component binding
references (the Bindings property reference on an ADF Faces component) were
stored in managed beans with a scope larger than request, which JavaServer
Faces component don't support.

 In his write-up Duncan documents the same
strategy I was about to document, which is to separate the value saving from the component reference
using different managed beans in different scope. Well, I think that Duncan's
blog entry saved me some time I today.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.