You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "sean schofield (JIRA)" <de...@myfaces.apache.org> on 2006/10/16 19:29:37 UTC

[jira] Commented: (TOMAHAWK-738) SaveState fails with a java.util.List implementation other than ArrayList

    [ http://issues.apache.org/jira/browse/TOMAHAWK-738?page=comments#action_12442650 ] 
            
sean schofield commented on TOMAHAWK-738:
-----------------------------------------

I discovered the reason why Catagay's fix breaks my code.  By not calling saveAttachedState for Serializable objects that do not implement StateHolder you will get an exception with the 1.2 RI when calling restoreAttachedState.  You really shouldn't call one without the other.  The spec is a little unclear on this and mentions only that restoreAttachedState is "tightly coupled" with saveAttachedState and is meant to be called to restore objects that were saved with that method.  

The real problem is that the MyFaces core seems to have a spec compliance issue.  The original problem was that a List could not be saved and only a StateHolder could be used.  That clearly violates the spec which says:

"This method supports saving attached objects of the following type: Objects, null values, and Lists of these objects. If any contained objects are not Lists  and do not implement StateHolder, they must have zero-argument public constructors. The exact structure of the returned object is undefined and opaque, but will be serializable."

I suggest we create a new bug in the core project (with a category of JSF spec compat) and then mark this bug as Won't Fix as well as link it to the new bug.  Finally, I suggest we add a new unit test to the core to expose the bug and make it similar to Catagay's test case.  Ideally we also change Catagay's test case for UISaveState to use mocks to verify that save and restoreAttachedState are being called (suggest JMock).  You don't really want the test to pass depending on which version of the JSF implementation you use.

> SaveState fails with a java.util.List implementation other than ArrayList
> -------------------------------------------------------------------------
>
>                 Key: TOMAHAWK-738
>                 URL: http://issues.apache.org/jira/browse/TOMAHAWK-738
>             Project: MyFaces Tomahawk
>          Issue Type: Bug
>          Components: UISaveState
>    Affects Versions: 1.1.4-SNAPSHOT
>            Reporter: Cagatay Civici
>         Assigned To: Cagatay Civici
>             Fix For: 1.1.4-SNAPSHOT
>
>
> restoreAttachedState of UIComponentBase wraps the lists as an ArrayList so restoring values fails when a list implementation other than an arraylist is used.
> An example;
>         private LinkedList list;
> 	private String name;
> 	private String surname;
> 	public LinkedList getList() {
> 		list = new LinkedList();
> 		list.add(name);
> 		list.add(surname);
> 		return list;
> 	}
> 	public void setList(LinkedList list) {
> 		name = (String)list.get(0);
> 		surname = (String)list.get(1);
> 	}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira