CloseAgent

From Documentation
Revision as of 10:07, 15 May 2012 by Hawk (talk | contribs)



Close

Due to ZK component's specifications, only panel, tab, and window supports this operation. Notice that when you close any of these components, the closed component is consequently detached from desktop by default. Of course, you can write event handler to override this behavior, for example to hide a component instead of detaching it.

Smalltalk-mimic-close.png


The test below is quite simple, close each component and check if they are detached one by one.

	@Test
	public void testAgent() {
		DesktopAgent desktopAgent = Zats.newClient().connect("/close.zul");
		
		ComponentAgent panel = desktopAgent.query("panel[title='closable']");
		panel.as(CloseAgent.class).close();
		Assert.assertNull(((Component)panel.getDelegatee()).getPage());
		
		ComponentAgent window = desktopAgent.query("window[title='closable']");
		window.as(CloseAgent.class).close();
		Assert.assertNull(((Component)window.getDelegatee()).getPage());
		
		ComponentAgent tab = desktopAgent.query("tab[label='closable']");
		tab.as(CloseAgent.class).close();
		Assert.assertNull(desktopAgent.query("tab[label='closable']"));
	}
  • Close a closeable component with CloseAgent.close() When the component is detached, do not reuse the variables that references them. (line 6,10,14)
  • After "tab" is detached, you cannot retrieve from desktop. (line 15)


Supported Components

Components
Version
Note
Panel 5, 6
Tab 5, 6
Window 5, 6




Last Update : 2012/05/15

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.