View scope reset fields to default after performing an action


Staff member
First of all, my beans are managed by spring not by JSF and I am using custom view scope as described in <a href="" rel="nofollow">this article</a>. So if the behavior is weird for regular JSF2 and might be related to Spring, please tell me.


public class DepartmentBean {

    private DefaultTreeModel model;

    public void preRender(ComponentSystemEvent event) throws Exception {
        if (model == null) {
            model = myService.buildModel();

    public String clear() {
        // resetting stuff
        return "pretty:";



    &lt;ice:panelGroup styleClass="crud-links"&gt;
        &lt;h:commandLink value="Delete" action="#{department.deleteDepartment}" /&gt;          
        &lt;ice:tree id="tree" value="#{department.model}" var="item" hideRootNode="false" hideNavigation="false" imageDir="./xmlhttp/css/xp/css-images/"&gt;
                &lt;f:facet name="content"&gt;
                    &lt;ice:panelGroup style="display: inline"&gt;
                        &lt;ice:commandLink  value="#{item.userObject.text}"&gt;&lt;/ice:commandLink&gt;

When page is loaded for first time the
object is populated with data, but when clicking delete button I notice that after clearing
method is executed and the model (which was populated before clearing becomes null, and gets populated again, although I am in same page, and it should maintain the value)

Does the code have a problem that leads to such behavior, or this is the normal behavior?
If the problem maybe related to Spring or the custom view scope or the IceFaces, please advise.

<strong>UPDATE</strong>- <strong>REQUIREMENT</strong>:

I want to initialize the tree model on construction of the page, and while i am still on the page the tree model doesn't gets initialized again until i do that programatically .