how to avoid serialization
cubrovicd Sep 30, 2010 6:03 AMHow to avoid serialization and recreation of my components from AjaxStateManager.
I have createt html form simple as
<h:messages globalOnly="true" styleClass="message" />
<h:form>
<rich:panel binding="#{formmain.frame}" id="mainframeid">
</rich:panel>
</h:form>
and all of the subpanels ,tabbed panels menus... (richfaces components) are created dynamically in my formmain session scoped bean.
After that all of page actions are executed during ajax (as I said richfaces components) so idea is never to reload that page again (classic reload) but to change it with ajax requests.
Well that parts works well for now but what make problem for me is saving and recreating of components.
Can I somehow tell to jsf to not saved my component and then creates it from the beggining but to use tha same component model that I stored in formmain.frame all the time.
When components are recreated I cant used references I have stored in my formmain (to tabbedpanel to footer...) so I have to traverse my component tree (formmain.frame children...) to find component I want to removed or add children to.
This makes things harder and not so clean in code.
I want to make some references from that components to some ejb beans so I wanted this components to be created only once!
(MyButton that extends ajaxbutton and have references to some ejb bean to execute action on.
Futhermore this is stacktrace in case it makes it easier to see wahat happening.
restoreView recreates components by creating my menuitem again on server and that seems ok but what I want it to do is to some how use the menuitem already created and added to #{formmain.frame} panel.
Can I achive that behavior. Am I wrong wanted to have this kind of behavior?
at com.incrementum.framework.form.seam.MenuItem.<init>(MenuItem.java:16)
02:36:17,675 ERROR [STDERR] at sun.reflect.GeneratedConstructorAccessor167.newInstance(Unknown Source)
02:36:17,675 ERROR [STDERR] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
02:36:17,675 ERROR [STDERR] at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
02:36:17,675 ERROR [STDERR] at java.lang.Class.newInstance0(Class.java:372)
02:36:17,675 ERROR [STDERR] at java.lang.Class.newInstance(Class.java:325)
02:36:17,675 ERROR [STDERR] at org.ajax4jsf.application.ComponentsLoaderImpl.createComponent(ComponentsLoaderImpl.java:40)
02:36:17,675 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:476)
02:36:17,675 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
02:36:17,675 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
02:36:17,675 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
02:36:17,675 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
02:36:17,675 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
02:36:17,675 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager.restoreView(AjaxStateManager.java:244)
02:36:17,675 ERROR [STDERR] at com.sun.faces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:311)
02:36:17,675 ERROR [STDERR] at org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:116)
02:36:17,675 ERROR [STDERR] at org.ajax4jsf.application.AjaxViewHandler.restoreView(AjaxViewHandler.java:159)
02:36:17,675 ERROR [STDERR] at org.jboss.seam.jsf.SeamViewHandler.restoreView(SeamViewHandler.java:93)
02:36:17,675 ERROR [STDERR] at com.sun.facelets.FaceletViewHandler.restoreView(FaceletViewHandler.java:316)
I trieed putting following in web.xml. Still same behaviour
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.SERIALIZE_SERVER_STATE</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.serializeServerState</param-name>
<param-value>false</param-value>
</context-param>
I changed my tabpanel form
htmlTabPanel.setSwitchType(UISwitchablePanel.AJAX_METHOD);
to
htmlTabPanel.setSwitchType(UISwitchablePanel.SERVER_METHOD);
still same stacktrace
Any pointers would be highly appreciated.
Danilo