Annotations

compared with
Current by Deryk Sinotte
on Feb 07, 2012 12:46.


 
Key
These lines were removed. This word was removed.
These lines were added. This word was added.

View page history


There are 2 changes. View first change.

 h1. Annotations
  
 h3. @org.icefaces.bean.ViewRetained
  ICEfaces provides custom annotations to enhance existing features and help manage the behaviour of additional features like Window-scoped beans:
  
 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:
  
 {code:title=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 {
 ...
 {code}
  
 h3. @org.icefaces.bean.WindowDisposed
  
 A view-scoped bean annotated with @WindowDisposed is removed from the View map when the browser window associated with that view is closed. With stock JavaServer Faces, view-scoped beans are disposed when the session expires. By using ICEfaces and the @WindowDisposed annotation, view-scoped beans can be disposed in a more timely fashion resulting in more efficient use of resources.
  
 {code:title=MyViewScopedBean.java with @WindowDisposed}
 package org.icefaces.demo;
  
 import javax.faces.bean.ManagedBean;
 import javax.faces.bean.ViewScoped;
 import java.io.Serializable;
  
 import org.icefaces.bean.WindowDisposed;
  
 @ManagedBean(name = "myViewScopedBean")
 @ViewScoped
 @WindowDisposed
 public class MyViewScopedBean implements Serializable {
 ...
 {code}
  {children}

© Copyright 2021 ICEsoft Technologies Canada Corp.