Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using view-scoped beans during the restore view phase

Marc Dergacz
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have come across an issue regarding the use of view-scoped beans on components where the value expression is evaluated as part of the buildView() process.

Essentially, it seems that the view scope is only restored AFTER the component tree has been built which means it is not possible to do the following:

<ui:include src="#{MyViewScopedBean.somePage}"/> or <h:panelGroup rendered="#{MyViewScopedBean.rendered}"/>

When the component tree is being created, the view scope is not available so JSF essentially looks in the session scope for 'MyViewScopedBean', doesn't find it and proceeds to generate a new view scoped object every single request.

Is this the intended behaviour of JSF 2.0? Are you only able to use application, session or request scoped beans on those component properties that are evaluated as part of building the view and would making a custom bean scope help solve this dilemma?

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic