0

Listbox: problem with paging of live data from entity with a field List

asked 2010-10-08 07:51:04 +0800

giordan gravatar image giordan
48 2

updated 2010-10-08 08:08:41 +0800

Hi to all!

I've a paged listbox with live data and a personalized renderer.

        ...
	<listbox id="lista" width="100%" mold="paging" pageSize="40">
		<listhead sizable="true">
			<listheader label="nPratica"/>
			<listheader label="Indirizzo"/>
			<listheader label="First Project Manager Name" />
		</listhead>
		<listitem forEach="${data};" >
		</listitem>
        </listbox>
	<zscript><![CDATA[
		...
		ListModel data = new SimpleListModel(cerca.getPratiche());
		lista.setModel(data); 
		ListitemRenderer myPraticaRenderer = new RendererPraticaRicerca();
		lista.setItemRenderer(myPraticaRenderer);
	]]></zscript>
	...

In my renderer I've managed the eventual null pointer and value, something like the follow:

	...
	public void render(Listitem li, Object data) {
		Pratica c = (Pratica)data;
		...
		String firstPMname = new String("No PM");
		try {
			if (c.getProjectManager().size()>0) {
				firstPMname = c.getProjectManager().get(0).getProfessionist().getName().toString();
			}
		}
		catch (Exception e) {
			firstPMname = "Problems to load";
		}
		new Listcell(firstPMname).setParent(li);
	...

The data come from a POJO entity Pratica with:
- simple attribute,
- class attribute (to map one to many relation) and
- List (to map many to many relation)

See bellow a little portion of the class Pratica

	...
	public class Pratica implements java.io.Serializable {
		private Long idPratica;
		private String nPratica;
		private Indirizzo indirizzo;
		private List<ProjectManager> projectManager = new LinkedList<ProjectManager>();
	...

All works very fine in the first page.
When I go to the next pages the listcells of the column linked to the the attribute "name" of the First ProjectManager in the List belonging to the Pratica class conteins the value "Problems to load" in ALL the listitem of the page, also when there exist one or more Project Manager per Pratica.

Where is the problem?
Can you help me to solve it?

Thanks in advance, best regards

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2010-10-10 20:12:31 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

Hi giordan,
What ZK version are you using?
You can try to remove

<listitem forEach="${data};" >
		</listitem>

and you can try to remove try catch to see what exception be happened.

link publish delete flag offensive edit

answered 2010-10-11 04:24:52 +0800

giordan gravatar image giordan
48 2

updated 2010-10-11 04:25:25 +0800

Hi as1225!

Thanks for your support.

The version of ZK that I'm using is 5.0.3.
I've tried to follow your suggestion and the result is the following exception:

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: ecodata.gestedil.model.Pratica.projectManager, no session or session was closed
	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
	at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:97)
	at org.hibernate.collection.PersistentBag.size(PersistentBag.java:225)
	at ecodata.gestedil.controller.RendererPraticaRicerca.render(RendererPraticaRicerca.java:38)
	at org.zkoss.zul.Listbox$Renderer.render(Listbox.java:2699)
	at org.zkoss.zul.Listbox.onInitRender(Listbox.java:2642)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.zkoss.zk.ui.impl.EventProcessor.process0(EventProcessor.java:208)
	at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:140)
	at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1462)
	at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1246)
	at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1026)
	at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:550)
	at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:441)
	at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:449)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:188)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Unknown Source)

How can I fix this?
Thanks, best regards

link publish delete flag offensive edit

answered 2010-10-12 02:26:52 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

You can refer to the following link
http://forum.springsource.org/showthread.php?t=64663

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-10-08 07:51:04 +0800

Seen: 305 times

Last updated: Oct 12 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More