Hi,

I'd like to discuss the latest issues about the savestate component.

In order to use the component with a value of type StateHolder, restoreAttachedState-saveAttachedState is used. But using them fails with list implementations other than arraylists.

See this one;

See this one; http://issues.apache.org/jira/browse/TOMAHAWK-738

It seems restoreAttachedState-saveAttachedState should only be used when the value is a stateholder, I've found an ugly solution to the problem as;

public Object saveState(FacesContext context)
    {
        Object values[] = new Object[2];
        values[0] = super.saveState(context);
        values[1] = getValue() instanceof StateHolder ? saveAttachedState(context, getValue()) : getValue();
        return values;
    }

    public void restoreState(FacesContext context, Object state)
    {
        Object values[] = (Object[])state;
        super.restoreState(context, values[0]);
        Object value = values[1].getClass().getName().equals(" javax.faces.component._AttachedStateWrapper") ? restoreAttachedState(context,values[1]) : values[1];
       
        ValueBinding vb = getValueBinding("value");
        if (vb != null)
        {
            vb.setValue(context, value);
        }
    }

Since _AttachedStateWrapper is private, I cant use instanceof, using class name is the ugly part. Other than that it works fine with all cases.

Any ideas about this?

Cagatay




Reply via email to