Hi catagay,

javax.faces.component._AttachedStateWrapper is pretty much myfaces_api isn't it?
so shouldn't be used inside the savastate custom comp.

can you explain why it is failing?

Thanks!


On 10/14/06, Cagatay Civici <[EMAIL PROTECTED]> wrote:
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







--
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Reply via email to