ViewRetained

Table of Contents

@org.icefaces.bean.ViewRetained

During postback navigation, where the result of a navigation event returns the same view id, the default behaviour for JavaServer Faces is to create a new view instance. This also means a new map of view-scoped beans where all the previous view-scoped beans are disposed and new instances created. By adding the @ViewRetained annotation to a bean in View scope, that bean instance is propagated across the navigation to the new view map. This only occurs during postback, where the id of the original view and the new view are the same. The benefit is that view-scoped beans can have consistent state during postback, and not appear to reset themselves.

To use the annotation, simply import it and add it to the class of the view-scoped bean that you'd like to retain:

MyViewScopedBean.java with @ViewRetained
package org.icefaces.demo;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import java.io.Serializable;

import org.icefaces.bean.ViewRetained;

@ManagedBean(name = "myViewScopedBean")
@ViewScoped
@ViewRetained
public class MyViewScopedBean implements Serializable {
...
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© Copyright 2018 ICEsoft Technologies Canada Corp.