Mixing AJAX and flow scope
AJAX requests are usually associated with beans in view scope (@ViewScoped
), which means that data can be persisted (stored) over multiple AJAX requests as long as the current view is not destroyed by a navigation case (or other causes). A flow is defined as a collection of logical related pages/views; therefore AJAX cannot survive across flow transitions.
For better understanding, we will adapt the application developed in Chapter 3, JSF Scopes – Lifespan and Use in Managed Beans Communication (the ch3_7_3
application, which you need to be familiar with) to support AJAX requests in the registration.xhtml
view (the first page in flow). The main idea is to write a view scoped bean that may populate the player name and surname defined in the flow scoped bean, RegistrationBean
. The view-scoped bean, named ViewRegistrationBean
, will randomly generate a name-surname pair and will present them as a suggestion to the end user. The user can provide the name and surname...