This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSF and the fly likes jsf binding and saved states Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "jsf binding and saved states" Watch "jsf binding and saved states" New topic
Author

jsf binding and saved states

Danilo Cubrovic
Greenhorn

Joined: Sep 19, 2010
Posts: 3

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.

Further more 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.

Any pointers would be highly appreciated.

Thanks in advance,
Danilo




Danilo Cubrovic
Greenhorn

Joined: Sep 19, 2010
Posts: 3
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)
Danilo Cubrovic
Greenhorn

Joined: Sep 19, 2010
Posts: 3

Anyone on this?

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 whena i change tab components from the tab have been recreated


06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.ComponentsLoaderImpl.createComponent(ComponentsLoaderImpl.java:40)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:476)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager$TreeStrutureNode.restore(AjaxStateManager.java:490)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxStateManager.restoreView(AjaxStateManager.java:244)
06:10:13,897 ERROR [STDERR] at com.sun.faces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:311)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:116)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxViewHandler.restoreView(AjaxViewHandler.java:159)
06:10:13,897 ERROR [STDERR] at org.jboss.seam.jsf.SeamViewHandler.restoreView(SeamViewHandler.java:93)
06:10:13,897 ERROR [STDERR] at com.sun.facelets.FaceletViewHandler.restoreView(FaceletViewHandler.java:316)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:116)
06:10:13,897 ERROR [STDERR] at org.ajax4jsf.application.AjaxViewHandler.restoreView(AjaxViewHandler.java:159)
06:10:13,897 ERROR [STDERR] at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:175)
06:10:13,897 ERROR [STDERR] at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
06:10:13,897 ERROR [STDERR] at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
06:10:13,897 ERROR [STDERR] at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
06:10:13,897 ERROR [STDERR] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)

Any ideas how to avoid this kind of serialization?
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: jsf binding and saved states
 
Similar Threads
rich:comboBox valueChangeListener is not working
binding
Struts2 with JSF and RichFace
Setting form action
Problem with JSF remembering old values