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

appending a component after its removal fails to initialize bindings

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 7.0.0, 6.5.5
    • 6.5.4
    • Databind 2
    • Windows 7, JDK 7, Tomcat 7

      since commit 881f5f1ce0a0fbc15bd0c71e801faf0ceed3027f (fix zk 1887...) and a87c0e0c3b5eb479908914adef227e2e4174e417 (refix/finetune fix of 1877), when removing a child component and then appending it, binding is not initialized.

      In the following example if "Button 1" is clicked after "Remove & Append", no notification will be shown.

      <zk>
      	<div apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('test.TestVM')">
      		<button label="Remove &amp; Append" onClick="@command('doRemoveAppend')" />
      		<div id="container">
      			<button id="btn1" label="Button 1" onClick="@command('doNotify',msg=self.label,type='info',ref=self,position='at_pointer',duration=1000)" />
      		</div>
      	</div>
      </zk>
      
      public class TestVM {
      	@Wire("#container")
      	private Div container;
      
      	@AfterCompose
      	public void afterCompose(@ContextParam(ContextType.VIEW) Component view) {
      		Selectors.wireComponents(view, this, false);
      	}
      
      	@Command
      	public void doRemoveAppend() {
      		Component c = container.getChildren().get(0);
      		container.removeChild(c);
      		container.appendChild(c);
      	}
      
      	@Command
      	public void doNotify(@BindingParam("msg") String msg,
      			@BindingParam("type") String type,
      			@BindingParam("ref") Component ref,
      			@BindingParam("position") String position,
      			@BindingParam("duration") Integer duration) {
      		Clients.showNotification(msg, type, ref, position, duration);
      	}
      }
      

            Unassigned Unassigned
            benedetti benedetti
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: