Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-1876

Bug with save-when and listbox

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • 6.5.2
    • Components, Databind
    • Spring Tool Suite 3.2.0
      ZK Studio 2.0.0
      Zk Release 6.5.2 Firefox 22 / IE 8

      Try this (source code below TestModel.java and test.zul) :

      • Click on first line (ENGLISH)
      • On the list box, select FRANCAIS
      • Click OK : you w'll encounter an excpmtion

      CAUTION :

      • It's working with ZK 6.0.0, 6.0.1
      • Since ZK 6.0.2 this sample below is not working

      Exception:

      juil. 31, 2013 4:31:56 PM org.zkoss.zk.ui.impl.UiEngineImpl handleError:1359
      SEVERE: >>java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
      >>	at org.zkoss.zk.ui.AbstractComponent$ChildIter.<init>(AbstractComponent.java:2848)
      >>	at org.zkoss.zk.ui.AbstractComponent$ChildIter.<init>(AbstractComponent.java:2840)
      >>	at org.zkoss.zk.ui.AbstractComponent$Children.listIterator(AbstractComponent.java:185)
      >>	at java.util.AbstractSequentialList.get(AbstractSequentialList.java:88)
      >>	at org.zkoss.zul.Combobox.getItemAtIndex(Combobox.java:614)
      >>	at org.zkoss.zkplus.databind.ComboitemCollectionItem.getComponentAtIndexByOwner(ComboitemCollectionItem.java:56)
      >>	at org.zkoss.zkplus.databind.DataBinder.getCollectionItems(DataBinder.java:810)
      >>	at org.zkoss.zkplus.databind.DataBinder.access$200(DataBinder.java:66)
      >>	at org.zkoss.zkplus.databind.DataBinder$LoadOnSaveEventListener.loadAllBindings(DataBinder.java:1557)
      >>	at org.zkoss.zkplus.databind.DataBinder$LoadOnSaveEventListener.myLoadAllNodes(DataBinder.java:1481)
      >>	at org.zkoss.zkplus.databind.DataBinder$LoadOnSaveEventListener.myLoadAllNodes(DataBinder.java:1511)
      >>	at org.zkoss.zkplus.databind.DataBinder$LoadOnSaveEventListener.loadAllNodes(DataBinder.java:1439)
      >>	at org.zkoss.zkplus.databind.DataBinder$LoadOnSaveEventListener.doLoad(DataBinder.java:1428)
      >>	at org.zkoss.zkplus.databind.DataBinder$LoadOnSaveEventListener.onEvent(DataBinder.java:1405)
      >>	at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:2742)
      >>	at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2713)
      >>	at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2654)
      >>	at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:136)
      >>	at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1717)
      >>	at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1502)
      >>	at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1212)
      >>	at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:600)
      >>	at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:482)
      >>	at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:491)
      >>	at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
      >>	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      >>	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      >>	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      >>	at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:180)
      >>	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      >>	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      >>	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      >>	at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
      >>	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      >>	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      >>	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      >>	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
      >>	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      >>	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      >>	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      >>	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      >>	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
      >>	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
      >>	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      >>	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
      >>	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      >>	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
      >>	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      >>	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
      >>	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      >>	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
      >>	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      >>	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
      >>	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      >>	at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
      >>	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      >>	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
      >>	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      >>	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
      >>	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      >>	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
      >>	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      >>	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
      >>	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
      >>	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
      >>	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
      >>	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      >>	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      >>	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      >>	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      >>	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      >>	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      >>	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      >>	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
      >>	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      >>	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      >>	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
      >>	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
      >>	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
      >>	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      >>	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      >>	at java.lang.Thread.run(Thread.java:724)
      

      test.zul :

      <?page title="new page title" contentType="text/html;charset=UTF-8"?>
      <?meta http-equiv="X-UA-Compatible" content="chrome=1"?>
      <zk>
      
      	<window id="test" apply="nc.mairie.temp.TestModel">
      
      
      		<div id="windowListWord">
      			<listbox id="listBoxWord" model="@{test.listWord}"
      				selectedItem="@{test.currentWord}" width="500px">
      				<listhead>
      					<listheader label="word" />
      					<listheader label="lang" />
      					<listheader label="fullName" />
      				</listhead>
      				<listitem self="@{each=word}">
      					<listcell label="@{word.word}" />
      					<listcell label="@{word.lang.language}" />
      					<listcell label="@{word.fullName}" />
      				</listitem>
      			</listbox>
      		</div>
      
      	<div id="detailWord"  visible="@{test.visible}">
      		<grid width="400px">
      			<rows>
      				<row>
      					First Name:
      					<textbox id="firstName"
      						value="@{test.currentWord.word, save-when='btnOk.onClick'}" />
      				</row>
      
      				<row>
      					Lang:
      						<combobox mold="rounded" 
      						model="@{test.listLang}"
      						selectedItem="@{test.currentWord.lang, save-when='btnOk.onClick'}">
      						<comboitem self="@{each=lang}"
      							label="@{lang.language}" />
      						</combobox>
      
      
      				</row>
      				<row>
      
      					Full Name:
      					<label id="fullName"
      						value="@{test.currentWord.fullName}" />
      				</row>
      				<row>
      				<button id="btnOk" label="Ok" />
      				</row>
      			</rows>
      		</grid>
      	</div>
      
      	</window>
      </zk>
      
      

      TestModel.jave:

      /**
       * 
       */
      package nc.mairie.temp;
      
      import java.util.ArrayList;
      
      import org.zkoss.zk.ui.Component;
      import org.zkoss.zk.ui.select.SelectorComposer;
      import org.zkoss.zk.ui.select.annotation.Listen;
      import org.zkoss.zk.ui.select.annotation.Wire;
      import org.zkoss.zkplus.databind.AnnotateDataBinder;
      import org.zkoss.zul.Div;
      import org.zkoss.zul.Window;
      
      
      /**
       * @author boulu72
       *
       */
      public class TestModel extends SelectorComposer<Component> {
      
      	/**
      	 * 
      	 */
      	private static final long serialVersionUID = -8608406922690897596L;
      
      	AnnotateDataBinder binder;
      	
      	ArrayList<Word> listWord;
      	
      	public ArrayList<Word> getListWord() {
      		return listWord;
      	}
      	
      	ArrayList <Lang> listLang = new ArrayList<Lang>();
      
      	public ArrayList<Lang> getListLang () {
      		return listLang;
      	}
      
      	
      	public static class Lang {
      		String name;
      		String language;
      		
      		Lang(String name, String language) {
      			this.name = name;
      			this.language = language;
      		}
      		
      		public String getName() {
      			return name;
      		}
      		public void setName(String name) {
      			this.name = name;
      		}
      		public String getLanguage() {
      			return language;
      		}
      		public void setLanguage(String language) {
      			this.language = language;
      		}
      		
      	}
      	
      	
      	Word currentWord;
      	
      	public static class Word {
        		String word;
        		Lang lang;
        		
        		Word(String word, Lang lang) {
        			this.word = word;
        			this.lang = lang;
        		}
        		
        		public String getWord() {
        			return word;
        		}
        		
        		public void setWord(String word) {
        			this.word = word;
        		}
        		
        		public Lang getLang() {
        			return lang;
        		}
        		
        		public void setLang(Lang lang) {
        			this.lang=lang;
        		}
        		
        		public String getFullName () {
        			return getWord() + " "+ getLang().getLanguage();
        		}
        		
        		
        	}
      	
      	boolean visible = false;
      
      	public Word getCurrentWord(){
      		return currentWord;
      	}
      	
      	public void setCurrentWord(Word word){
      		this.currentWord= word;
      	}
      	
      	public boolean isVisible() {
      		return visible;
      	}
      
      	
      	@Wire
      	Div detailWord;
      	
      	@Wire
      	Window test;
      	
      	@Override
      	public void doAfterCompose(Component comp) throws Exception {
      		super.doAfterCompose(comp);
      	
      		Lang l1 = new Lang("eng","ENGLISH");
      		Lang l2 = new Lang("fr","FRANCAIS");
      		
      		listLang.add(l1);
      		listLang.add(l2);
      		
      		Word p1 = new Word("Hello", listLang.get(0));
      	    Word p2 = new Word("Coucou", listLang.get(1));
      	    
      	    listWord = new ArrayList<Word>();
      	    listWord.add(p1);
      	    listWord.add(p2);
      	    
      		comp.setAttribute(comp.getId(), this, true);
      				
      		binder = new AnnotateDataBinder(comp);
      		System.out.println(binder.isLoadOnSave());
      		//OBLIGE DE METTRE à FALSE pour ne pas avoir le bug de save-whn... pas terrible
      		//binder.setLoadOnSave(false);
      		binder.loadAll();
      
      	}
      
      	@Listen("onClick = #listBoxWord;")
      	public void onClick$listBoxWord() {
      		visible = true;
      		binder.loadComponent(detailWord);
      	}
      	
      	@Listen("onClick = #btnOk;")
      	public void onClick$btnOk() {
      		//visible = false;
      		//OBLIGE DE raffraichir TOUTE la fenêtre car loadOnSave est à faux :(
      		binder.loadComponent(test);
      		//binder.loadComponent(detailWord);
      	}
      	
      }
      
      

            Unassigned Unassigned
            dsised dsised
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: