restoreAttachedState and saveAttachedState

If you had come across a situation where you wanted to restore state of a non-primitive member variable, and found that it was not working, here is the solution:
public void restoreState(FacesContext context, Object state) {
Object[] values = (Object[]) state;
super.restoreState(context, values[0]);

//Don' do this; it will fail on you!!!
//listenerPointers = (Map<String, ArrayList<Class<? extends ActionListener>>>) values[1];

//This will work!!!
listenerPointers = (Map<String, ArrayList<Class<? extends ActionListener>>>) restoreAttachedState(context,values[1]);
Notice the call to restoreAttachedState(facesContext, value).

"saveAttachedState(facesContext, value) is the saveState() counter-part.

Both are static methods in UIComponentBase class.

RichFaces - selfRendered a4j:Region

For the selfRendered <a4j:region> to work properly, all the components embedded inside it should be UIComponents. In other words, if any html elements are part of the a4j:region, these elements are considered "transient" by the Richfaces framework and hence are lost-in-transit on post-back. If you have "div" tags, change them to t:divs (from Apache Tomahawk Library) or "span" to "h:outptText".