org.zkoss.zk.ui.util
Class Clients

java.lang.Object
  extended by org.zkoss.zk.ui.util.Clients

public class Clients
extends java.lang.Object

Utilities to send AuResponse to the client.

Utilities here are mainly to control how the client (aka., the browser window) behaves. To get the status, you might refer to ClientInfoEvent.

Author:
tomyeh
See Also:
ClientInfoEvent

Constructor Summary
Clients()
           
 
Method Summary
static void clearBusy()
          Cleans the busy message at the browser.
static void clearBusy(Component comp)
          Clears the busy message at the browser that covers only the specified component.
static void clearWrongValue(Component comp)
          Closes the error message of the specified component, if any, at the browser.
static void clearWrongValue(Component[] comps)
          Closes the error message of the specified components, if any, at the browser.
static void clearWrongValue(java.util.List comps)
          Closes the error message of the specified components, if any, at the browser.
static void closeErrorBox(Component comp)
          Deprecated. As of release 5.0.0, replaced with clearWrongValue(Component).
static void closeErrorBox(Component[] comps)
          Deprecated. As of release 5.0.0, replaced with clearWrongValue(Component[]).
static void closeErrorBox(java.util.List comps)
          Deprecated. As of release 5.0.0, replaced with clearWrongValue(List).
static void confirmClose(java.lang.String mesg)
          Asks the browser to confirm users whether to close the browser window.
static void evalJavaScript(java.lang.String javaScript)
          Asks the browser to evaluate the specified JavaScript.
static void moveBy(int x, int y)
          Moves the current desktop (aka., browser window) by the specified number of pixels.
static void moveTo(int x, int y)
          Moves the current desktop (aka., browser window) to the specified location (in pixels).
static void print()
          Asks the client to print the current desktop (aka., browser window).
static void reloadMessages(java.util.Locale locale)
          Reloads the client-side messages in the specified locale.
static void resizeBy(int x, int y)
          Resizes the current desktop (aka., browser window) by the specified number of pixels.
static void resizeTo(int x, int y)
          Resizes the current desktop (aka., browser window) to the specified size (in pixels).
static void response(AuResponse response)
          Sends an AU response (AuResponse)to the client with response's command (AuResponse.getCommand()) as the key.
static void response(java.lang.String key, AuResponse response)
          Sends an AU response (AuResponse) to the client with the specified key.
static void scrollBy(int x, int y)
          Scrolls the current desktop (aka., browser window) by the specified number of pixels.
static void scrollIntoView(Component cmp)
          Scrolls the ancestor elements to make the specified element visible.
static void scrollTo(int x, int y)
          Scrolls the current desktop (aka., browser window) to the specified location (in pixels).
static void showBusy(Component comp, java.lang.String msg)
          Shows the busy message at the browser that covers only the specified component.
static void showBusy(java.lang.String msg)
          Shows the busy message at the brower such that the user knows the system is busy.
static void showBusy(java.lang.String msg, boolean open)
          Deprecated. As of release 5.0.0, replaced with showBusy(String) and clearBusy().
static void submitForm(Component form)
          Submits the form with the specified form.
static void submitForm(java.lang.String formId)
          Submits the form with the specified ID.
static void wrongValue(Component comp, java.lang.String msg)
          Shows an error message for the specified component, if any, at the browser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Clients

public Clients()
Method Detail

response

public static final void response(AuResponse response)
Sends an AU response (AuResponse)to the client with response's command (AuResponse.getCommand()) as the key.

Since response's command is used as the key, so the second invocation of this method with a response that has the same command will override the previous one. For example, the first one will be ignored since both have the same command.


        response(new AuShowBusy("this will have no effect"));
        response(new AuClearBusy());

If this is an issue, use response(String, AuResponse) instead.

Since:
3.0.0

response

public static final void response(java.lang.String key,
                                  AuResponse response)
Sends an AU response (AuResponse) to the client with the specified key.

Parameters:
key - could be anything. The second invocation of this method in the same execution with the same key will override the previous one. In other words, the previous one will be dropped. If null is specified, the response is simply appended to the end without overriding any previous one.
Since:
3.0.4

confirmClose

public static final void confirmClose(java.lang.String mesg)
Asks the browser to confirm users whether to close the browser window.

If an non-null (non-empty) string is set, the browser will show up a confirmation dialog when an user tries to close the browser window, or browse to another URL. To reset (i.e., not showing any confirmation dialog), just call this method again with null.

Parameters:
mesg - the message to show when confirming users. If null (default) or emtpy, users can close the browser window directly.

wrongValue

public static final void wrongValue(Component comp,
                                    java.lang.String msg)
Shows an error message for the specified component, if any, at the browser.

You have to clear the error message manually with clearWrongValue(org.zkoss.zk.ui.Component).

Since:
5.0.0

clearWrongValue

public static final void clearWrongValue(Component comp)
Closes the error message of the specified component, if any, at the browser.

Since:
5.0.0

clearWrongValue

public static final void clearWrongValue(java.util.List comps)
Closes the error message of the specified components, if any, at the browser.

Since:
5.0.0

clearWrongValue

public static final void clearWrongValue(Component[] comps)
Closes the error message of the specified components, if any, at the browser.

Since:
5.0.0

closeErrorBox

public static final void closeErrorBox(Component comp)
Deprecated. As of release 5.0.0, replaced with clearWrongValue(Component).


closeErrorBox

public static final void closeErrorBox(java.util.List comps)
Deprecated. As of release 5.0.0, replaced with clearWrongValue(List).


closeErrorBox

public static final void closeErrorBox(Component[] comps)
Deprecated. As of release 5.0.0, replaced with clearWrongValue(Component[]).


submitForm

public static final void submitForm(java.lang.String formId)
Submits the form with the specified ID.


submitForm

public static final void submitForm(Component form)
Submits the form with the specified form. It assumes the form component is a HTML form.


print

public static void print()
Asks the client to print the current desktop (aka., browser window).


scrollIntoView

public static final void scrollIntoView(Component cmp)
Scrolls the ancestor elements to make the specified element visible.

Since:
3.6.1

scrollBy

public static final void scrollBy(int x,
                                  int y)
Scrolls the current desktop (aka., browser window) by the specified number of pixels. If the number passed is positive, the desktop is scrolled down. If negative, it is scrolled up.

See Also:
scrollTo(int, int)

scrollTo

public static final void scrollTo(int x,
                                  int y)
Scrolls the current desktop (aka., browser window) to the specified location (in pixels).

See Also:
scrollBy(int, int)

resizeBy

public static final void resizeBy(int x,
                                  int y)
Resizes the current desktop (aka., browser window) by the specified number of pixels. If the numbers passed are positive, the desktop size is increased. Negative numbers reduce the size of the desktop.

See Also:
resizeTo(int, int)

resizeTo

public static final void resizeTo(int x,
                                  int y)
Resizes the current desktop (aka., browser window) to the specified size (in pixels).

See Also:
resizeBy(int, int)

moveBy

public static final void moveBy(int x,
                                int y)
Moves the current desktop (aka., browser window) by the specified number of pixels. If the number passed is positive, the desktop is moved down. If negative, it is moved up.

See Also:
moveTo(int, int)

moveTo

public static final void moveTo(int x,
                                int y)
Moves the current desktop (aka., browser window) to the specified location (in pixels).

See Also:
moveBy(int, int)

evalJavaScript

public static final void evalJavaScript(java.lang.String javaScript)
Asks the browser to evaluate the specified JavaScript.

It has no effect if the client doesn't support JavaScript.

Parameters:
javaScript - the javaScript codes to run at the browser

showBusy

public static final void showBusy(java.lang.String msg)
Shows the busy message at the brower such that the user knows the system is busy.

It is usually used with Events.echoEvent(java.lang.String, org.zkoss.zk.ui.Component, java.lang.String) to prevent the user to click another buttons or components.

To cover only a particular component, use showBusy(Component, String). To close, use clearBusy().

Parameters:
msg - the message to show. If null, the default message (processing) is shown.
Since:
5.0.0
See Also:
clearBusy()

clearBusy

public static final void clearBusy()
Cleans the busy message at the browser.

Since:
5.0.0
See Also:
showBusy(String)

showBusy

public static final void showBusy(java.lang.String msg,
                                  boolean open)
Deprecated. As of release 5.0.0, replaced with showBusy(String) and clearBusy().


showBusy

public static final void showBusy(Component comp,
                                  java.lang.String msg)
Shows the busy message at the browser that covers only the specified component. It is used to denote a portion of the desktop is busy, and the user still can access the other part. In other words, it means there is a long operation taking place.

To execute a long operation asynchronously, the developer can use a working thread, or use EventQueue.subscribe(org.zkoss.zk.ui.event.EventListener,boolean).

See also Long Operations

Parameters:
comp - the component that the busy message to cover. Ignored if null. Notice that if the component is not found, the busy message won't be shown. In additions, the busy message is removed automatically if the component is detached later. To manually remove the busy message, use clearBusy(Component)
msg - the message to show. If null, the default message (processing) is shown.
Since:
5.0.0
See Also:
clearBusy(Component)

clearBusy

public static final void clearBusy(Component comp)
Clears the busy message at the browser that covers only the specified component.

Parameters:
comp - the component that the busy message to cover.
Since:
5.0.0
See Also:
showBusy(Component, String)

reloadMessages

public static final void reloadMessages(java.util.Locale locale)
                                 throws java.io.IOException
Reloads the client-side messages in the specified locale. It is used if you allow the user to change the locale dynamically.

Notice that this method only reloads the standard messages. The application has to update the component's content (such as labels) manually if necessary.

Limitation: it reloads only the messages of ZK Client Engine and ZUL components. It does not reload messages loaded by your own JavaScript codes.

Parameters:
locale - the locale. If null, Locales.getCurrent() is assumed.
Throws:
java.io.IOException
Since:
3.6.3


Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo