Useful Java Utilities"
Jumperchen (talk | contribs) |
|||
Line 40: | Line 40: | ||
This class offers a collection of methods which manipulate client side via AU Response. | This class offers a collection of methods which manipulate client side via AU Response. | ||
− | + | ==evalJavaScript== | |
[http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/util/Clients.html#evalJavaScript%28java.lang.String%29 Clients.evalJavaScript()] | [http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/util/Clients.html#evalJavaScript%28java.lang.String%29 Clients.evalJavaScript()] | ||
Line 49: | Line 49: | ||
</source> | </source> | ||
− | + | ==scrollIntoView== | |
[http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/util/Clients.html#scrollIntoView(org.zkoss.zk.ui.Component) Clients.scrollIntoView()] | [http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/util/Clients.html#scrollIntoView(org.zkoss.zk.ui.Component) Clients.scrollIntoView()] | ||
Scrolls the parent of the given component, so the given one become visible in the view. | Scrolls the parent of the given component, so the given one become visible in the view. | ||
− | + | ==showBusy/clearBusy== | |
[http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/util/Clients.html#showBusy(java.lang.String) Clients.showBusy()] | [http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/util/Clients.html#showBusy(java.lang.String) Clients.showBusy()] | ||
Line 67: | Line 67: | ||
[[Image:ZKDevRef_UIPattern_UsefulJavaUtil_Clients_showBusy.png]] | [[Image:ZKDevRef_UIPattern_UsefulJavaUtil_Clients_showBusy.png]] | ||
− | + | ==showNotification== | |
[since 6.0.1] | [since 6.0.1] | ||
[http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/util/Clients.html#showNotification(java.lang.String) Clients.showNotification()] | [http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/util/Clients.html#showNotification(java.lang.String) Clients.showNotification()] | ||
− | Show a notification box, which is dismissed upon left click (like Popup). You can either display a global notification (bigger) or one specific to another component (smaller with arrow pointing to it). | + | Show a notification box, which is dismissed upon left click (like Popup). You can either display a global notification (bigger) or one specific to another component (smaller with an arrow pointing to it). |
<source lang="java"> | <source lang="java"> | ||
Line 94: | Line 94: | ||
[[Image:ZKDevRef_UIPattern_UsefulJavaUtil_Clients_showNotification03.png]] | [[Image:ZKDevRef_UIPattern_UsefulJavaUtil_Clients_showNotification03.png]] | ||
+ | === Closable === | ||
[since 6.5.0] | [since 6.5.0] | ||
Notification now supports closable to let user close the notification box manually. | Notification now supports closable to let user close the notification box manually. | ||
<source lang="java"> | <source lang="java"> | ||
− | + | // add close icon on the top right corner of notification box | |
+ | Clients.showNotification(msg, closable); | ||
</source> | </source> | ||
[[Image:ZKDevRef_UIPattern_UsefulJavaUtil_Clients_showNotification04.png]] | [[Image:ZKDevRef_UIPattern_UsefulJavaUtil_Clients_showNotification04.png]] | ||
+ | |||
+ | |||
+ | === Multiline === | ||
+ | To show a multiline message, just append <tt><br/></tt> in the message string. | ||
+ | <source lang='java'> | ||
+ | Clients.showNotification("msg1 <br/> msg2 <br/>"); | ||
+ | </source> | ||
=Version History= | =Version History= |
Revision as of 08:46, 25 May 2017
In this section we introduce some of the most commonly used Java utility classes.
Executions
getCurrent
Retrieves the current execution (request/response).
createComponents
With this method, you can create components defined in another zul file and attach them to the current page.
sendRedirect
Redirects to another URL. If the parameter is left null, it will redirect to the current page.
Sessions
getCurrent
Retrieves the current session.
Clients
This class offers a collection of methods which manipulate client side via AU Response.
evalJavaScript
This method sends an AU Response to execute the given JavaScript on client side, which is the standard way of calling JavaScript from server side in ZK. For example,
Clients.evalJavaScript("zk.log('Hi.');");
scrollIntoView
Scrolls the parent of the given component, so the given one become visible in the view.
showBusy/clearBusy
Display/dismiss a busy icon, so user knows server is working or has finished working on something. For example,
Clients.showBusy(window, "Waiting for server...");
showNotification
[since 6.0.1]
Show a notification box, which is dismissed upon left click (like Popup). You can either display a global notification (bigger) or one specific to another component (smaller with an arrow pointing to it).
Clients.showNotification(msg); // display a global notification box
Clients.showNotification(msg, component); // display a notification box pointing to a component
You can also specify its position, style, and duration (for auto-dismiss):
Clients.showNotification(msg, type, component, position, duration);
Type determines the style of the notification box.
Here are the available positions:
Closable
[since 6.5.0]
Notification now supports closable to let user close the notification box manually.
// add close icon on the top right corner of notification box
Clients.showNotification(msg, closable);
Multiline
To show a multiline message, just append
in the message string.
Clients.showNotification("msg1 <br/> msg2 <br/>");
Version History
Version | Date | Content |
---|---|---|
6.0.1 | March 2012 | Add Clients.showNotification() |
6.5.0 | July 2012 | ZK-1145: Notification supports closable |