NotSerializableException for UIComponents

Sometimes I am getting ‘bugs’ that claim there is something wrong with the (Trinidad) framework, as its UIComponents are NOT serializable… An example:

java.io.NotSerializableException:
org.apache.myfaces.trinidad.component.UIXSwitcher

No, this is not a bug at all!

First:
Your (session/application/pageFlow scoped) backing beans should not have an UI component as its property… (if you really really need the “cool” binding attribute).

Second:
UIComponents are not serializable – for a good reason!
In JSF there is StateSaving (see the restore/saveState() hooks)….

Apache MyFaces Trinidad does have a tool that helps to store an reference to an UIComponent (instead of the component itself).

Here are a few blogs on that, that may give more information on the API and why the tool is there:

http://matthiaswessendorf.wordpress.com/2010/03/31/uicomponent-references-in-session-scoped-jsf-beans/

http://leadingyouastray.blogspot.com/2010/02/references-to-uicomponents-in-session.html

Have fun!

About these ads

Howdy!

Posted in apache, java, jsf, myfaces, trinidad

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 34 other followers

%d bloggers like this: