org.zkoss.zk.device
Class Devices

java.lang.Object
  extended by org.zkoss.zk.device.Devices

public class Devices
extends java.lang.Object

A manager of devices (Device).

Since:
2.4.0
Author:
tomyeh

Method Summary
static void add(org.zkoss.idom.Element config)
          Adds a device based on the XML declaration.
static java.lang.String add(java.lang.String type, java.lang.String cls)
          Adds a device.
static boolean exists(java.lang.String type)
          Tests whether the device for the specified type exists.
static java.lang.String getTimeoutURI(java.lang.String type)
          Returns the timeout URI for the specified device type.
static java.lang.String getUnavailableMessage(java.lang.String type)
          Returns the unavailable message for the specified device type.
static Device newDevice(Desktop desktop)
          Returns the device for the specified desktop.
static java.lang.String setTimeoutURI(java.lang.String type, java.lang.String timeoutURI)
          Sets the timeout URI for the specified device type.
static java.lang.String setUnavailableMessage(java.lang.String type, java.lang.String msg)
          Sets the unavailable message for the specified device type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newDevice

public static final Device newDevice(Desktop desktop)
Returns the device for the specified desktop.

Parameters:
desktop - the desktop to create a device and associate with.
Throws:
DeviceNotFoundException - if not found.
Since:
2.4.0

exists

public static final boolean exists(java.lang.String type)
Tests whether the device for the specified type exists.

Parameters:
type - the device type, say, ajax.
Since:
2.4.0

add

public static final java.lang.String add(java.lang.String type,
                                         java.lang.String cls)
Adds a device.

Parameters:
type - the device type (aka., the device name).
cls - the device class name
Returns:
the previous class of the device with the same type, if any, or null if no such device.

getUnavailableMessage

public static final java.lang.String getUnavailableMessage(java.lang.String type)
Returns the unavailable message for the specified device type.

Note: the current device (the device associated with the current desktop) might have a different message.

See Also:
Device, Device.getUnavailableMessage()

setUnavailableMessage

public static final java.lang.String setUnavailableMessage(java.lang.String type,
                                                           java.lang.String msg)
Sets the unavailable message for the specified device type. It affects only the devices (Device) that are created for the new desktops. The message for the devices that are already instantiated are not changed.

Returns:
the previous unavailable message if any.
See Also:
Device, Device.setUnavailableMessage(java.lang.String)

getTimeoutURI

public static final java.lang.String getTimeoutURI(java.lang.String type)
Returns the timeout URI for the specified device type. It is used to show the error message if the desktop being requested is not found. It is usually caused by session timeout.

Default: null (to shown an error message).

Note: the current device (the device associated with the current desktop) might have a different timeout URI.


setTimeoutURI

public static final java.lang.String setTimeoutURI(java.lang.String type,
                                                   java.lang.String timeoutURI)
Sets the timeout URI for the specified device type. It is used to show the error message if the desktop being requested is not found. It is usually caused by session timeout.

Parameters:
timeoutURI - the timeout URI. If empty, it means to reload the same page. If null, an error message is shown instead of redirecting to another page.
Returns:
the previous timeout URI if any.

add

public static final void add(org.zkoss.idom.Element config)
Adds a device based on the XML declaration.

<device-config>
  <device-type>superajax</device-type>
  <device-class>my.MyDevice</device-class>
  <unavailable-message>error message</unavailable-message>
</device-config>
 

Parameters:
config - the XML element called zscript-config


Copyright © 2005-2007 Potix Corporation. All Rights Reserved.