Class OpenEvent

java.lang.Object
org.zkoss.zk.ui.event.Event
org.zkoss.zk.ui.event.OpenEvent
All Implemented Interfaces:
Serializable

public class OpenEvent extends Event
Represents an event cause by user's opening or closing something at the client.

Note: it is a bit confusing but Events.ON_CLOSE is sent when user clicks a close button. It is a request to ask the server to close a window, a tab or others. If the server ignores the event, nothing will happen at the client. By default, the component is detached when receiving this event.

On the other hand, Events.ON_OPEN (with OpenEvent) is a notification. It is sent to notify the server that the client has opened or closed something. And, the server can not prevent the client from opening or closing.

Author:
tomyeh
See Also:
  • Constructor Details

    • OpenEvent

      public OpenEvent(String name, Component target, boolean open)
      Constructs an onOpen event.
      Parameters:
      open - whether the new status is open
    • OpenEvent

      public OpenEvent(String name, Component target, boolean open, Component ref)
      Constructs an onOpen event for a context menu, a tooltip or a popup.
      Parameters:
      target - the component being opened
      ref - the component that causes target to be opened.
    • OpenEvent

      public OpenEvent(String name, Component target, boolean open, Component ref, Object value)
      Constructs an onOpen event.
      Parameters:
      open - whether the new status is open
      value - the current value of the target component if applicable.
      Since:
      3.5.0
      See Also:
  • Method Details

    • getOpenEvent

      public static final OpenEvent getOpenEvent(AuRequest request)
      Converts an AU request to an open event.
      Since:
      5.0.0
    • getReference

      public Component getReference()
      Returns the reference that causes Event.getTarget() to be opened.

      It is null, if the open event is not caused by opening a context menu, a tooltip or a popup. Note: the onOpen event is also sent when closing the context menu (tooltip and popup), and this method returns null in this case. Thus, it is better to test isOpen() or getReference() before accessing the returned value. if (event.isOpen()) doSome(event.getReference());

    • isOpen

      public boolean isOpen()
      Returns whether it causes open.
    • getValue

      public Object getValue()
      Returns the value of the target component, when the onOpen event is sent, or null if not applicable.

      Note: combobox, bandbox and other combo-type input don't send the onChange event when the dropdown is opened (onOpen). Thus, if you want to do something depends on the value, use the value returned by this method. Furthermore, for combobox and bandbox, the return value is a non-null String instance.

      Since:
      3.5.0