CloseAgent"
From Documentation
m (correct highlight (via JWB)) |
|||
Line 13: | Line 13: | ||
The test below is quite simple, close each component and check if they are detached one by one. | The test below is quite simple, close each component and check if they are detached one by one. | ||
− | <source lang="java" | + | <source lang="java" highlight="6,10,14,15"> |
@Test | @Test | ||
Line 33: | Line 33: | ||
</source> | </source> | ||
− | * Close a closeable component with < | + | * Close a closeable component with <code> CloseAgent.close() </code> 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) | * After "tab" is detached, you cannot retrieve from desktop. (line 15) |
Latest revision as of 02:55, 18 January 2022
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.
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
Panel, Tab, Window | 5, 6 |