This will not work. If the bean view is serialized, all transient fields are skipped. After deserialization, JSF does not restore managed properties, so you fall into the scope of a bean without the scope bean property, which only calls NPE.
In this particular design, it is best to introduce lazy loading into the getter and get the bean session by the receiver instead of directly accessing the field.
private transient SessionBeany sessionBeany; public SessionBeany getSessionBeany() { // Method can be private. if (sessionBeany == null) { FacesContext context = FacesContext.getCurrentInstance(); sessionBeany = context.getApplication().evaluateExpressionGet(context, "#{sessionBeany}", SessionBeany.class); } return sessionBeany; }
source share