org.zkoss.zul.impl
Class XulElement

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zk.ui.HtmlBasedComponent
          extended by org.zkoss.zul.impl.XulElement
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, HtmlBasedComponent, Component, Scope, ComponentCtrl, XulElement
Direct Known Subclasses:
Applet, Audio, Auxhead, Bandpopup, Box, Calendar, Columnchildren, Columnlayout, Detail, Div, Fisheye, Fisheyebar, Foot, Grid, Groupbox, HeadersElement, Html, Iframe, Image, Include, InputElement, Label, LabelElement, LayoutRegion, Listbox, Listfoot, Listitem, Menubar, Menuseparator, Paging, Panel, Panelchildren, Popup, Portalchildren, Portallayout, Progressmeter, Radiogroup, Row, Rows, Separator, Slider, Span, Splitter, Tabbox, Tablechildren, Tablelayout, Tabpanel, Tabpanels, Tabs, Toolbar, Tree, Treechildren, Treefoot, Treeitem, Treerow, Window

public abstract class XulElement
extends HtmlBasedComponent
implements XulElement

The fundamental class for XUL elements.

Events:
onOK, onCacnel and onCtrlKey.

Since:
3.0.6 supports onOK event., 3.0.6 supports onCancel event., 3.0.6 supports onCtrlKey event.
Author:
tomyeh
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent
HtmlBasedComponent.ExtraCtrl
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children
 
Field Summary
 
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_zclass, RS_NO_DISPLAY, RS_NO_HEIGHT, RS_NO_WIDTH
 
Fields inherited from class org.zkoss.zk.ui.AbstractComponent
_visible
 
Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
 
Constructor Summary
XulElement()
           
 
Method Summary
 java.lang.String getAction()
          Returns the client-side action (CSA).
protected  java.lang.String getActionAttrs()
          Returns the HTML attributes representing the client-side action, or "" if no client-side action is defined.
protected  java.lang.String getAllOnClickAttrs(boolean ignoreOnClick)
          Deprecated. As of release 3.0.5, replaced with HtmlBasedComponent.getAllOnClickAttrs(). If you want to generate only onDoubleClick and onRightClick, use

appendAsapAttr(sb, Events.ON_DOUBLE_CLICK);
appendAsapAttr(sb, Events.ON_RIGHT_CLICK);
 java.lang.String getContext()
          Returns the ID of the popup (Popup) that should appear when the user right-clicks on the element (aka., context menu).
 java.lang.String getCtrlKeys()
          Returns what keystrokes to intercept.
 java.lang.String getInnerAttrs()
          Generates the Client-Side-Action attributes to the interior tag.
 java.lang.String getOuterAttrs()
          Returns the exterior attributes for generating the enclosing HTML tag; never return null.
 java.lang.String getPopup()
          Returns the ID of the popup (Popup) that should appear when the user clicks on the element.
 java.lang.String getTooltip()
          Returns the ID of the popup (Popup) that should be used as a tooltip window when the mouse hovers over the element for a moment.
 void setAction(java.lang.String action)
          Sets the client-side action.
 void setContext(Popup popup)
          Sets the UUID of the popup that should appear when the user right-clicks on the element (aka., context menu).
 void setContext(java.lang.String context)
          Sets the ID of the popup (Popup) that should appear when the user right-clicks on the element (aka., context menu).
 void setCtrlKeys(java.lang.String ctrlKeys)
          Sets what keystrokes to intercept.
 void setPopup(Popup popup)
          Sets the UUID of the popup that should appear when the user clicks on the element.
 void setPopup(java.lang.String popup)
          Sets the ID of the popup (Popup) that should appear when the user clicks on the element.
 void setTooltip(Popup popup)
          Sets the UUID of the popup that should be used as a tooltip window when the mouse hovers over the element for a moment.
 void setTooltip(java.lang.String tooltip)
          Sets the ID of the popup (Popup) that should be used as a tooltip window when the mouse hovers over the element for a moment.
 
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
focus, getAllOnClickAttrs, getDraggable, getDroppable, getHeight, getLeft, getMoldSclass, getRealSclass, getRealStyle, getRealStyleFlags, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZclass, getZindex, getZIndex, newExtraCtrl, redraw, setClass, setDraggable, setDroppable, setFocus, setHeight, setLeft, setMoldSclass, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZclass, setZindex, setZIndex
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addEventHandler, addEventListener, addForward, addForward, addForward, addForward, addMoved, addSharedAnnotationMap, addSharedEventHandlerMap, appendAsapAttr, appendAsapAttr, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, clone, containsVariable, detach, disableClientUpdate, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttributes, getAttributes, getChildren, getCommand, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getExtraCtrl, getFellow, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getMoldURI, getNamespace, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getUuid, getVariable, hasFellow, insertBefore, invalidate, isAsapRequired, isChildable, isInvalidated, isListenerAvailable, isVisible, newChildren, onChildAdded, onChildRemoved, onDrawNewChild, onPageAttached, onPageDetached, onWrongValue, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, response, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setComponentDefinition, setId, setMold, setPage, setPageBefore, setParent, setVariable, setVisible, smartUpdate, smartUpdate, smartUpdate, smartUpdateDeferred, smartUpdateValues, toString, unsetVariable
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.zkoss.zk.ui.api.HtmlBasedComponent
focus, getHeight, getLeft, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZclass, getZindex, getZIndex, setDraggable, setDroppable, setFocus, setHeight, setLeft, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZclass, setZindex, setZIndex
 
Methods inherited from interface org.zkoss.zk.ui.Component
addEventListener, addForward, addForward, addForward, addForward, appendChild, applyProperties, clone, containsVariable, detach, getAttribute, getAttribute, getAttributes, getAttributes, getChildren, getDefinition, getDesktop, getFellow, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNamespace, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getUuid, getVariable, insertBefore, invalidate, isChildable, isInvalidated, isListenerAvailable, isVisible, redraw, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, setAttribute, setAttribute, setId, setMold, setPage, setPageBefore, setParent, setVariable, setVisible, unsetVariable
 

Constructor Detail

XulElement

public XulElement()
Method Detail

getCtrlKeys

public java.lang.String getCtrlKeys()
Returns what keystrokes to intercept.

Default: null.

Specified by:
getCtrlKeys in interface XulElement
Since:
3.0.6

setCtrlKeys

public void setCtrlKeys(java.lang.String ctrlKeys)
                 throws UiException
Sets what keystrokes to intercept.

The string could be a combination of the following:

^k
A control key, i.e., Ctrl+k, where k could be a~z, 0~9, #n
@k
A alt key, i.e., Alt+k, where k could be a~z, 0~9, #n
$n
A shift key, i.e., Shift+n, where n could be #n. Note: $a ~ $z are not supported.
#home
Home
#end
End
#ins
Insert
#del
Delete
#left
Left arrow
#right
Right arrow
#up
Up arrow
#down
Down arrow
#pgup
PageUp
#pgdn
PageDn
#f1 #f2 ... #f12
Function keys representing F1, F2, ... F12

For example,

^a^d@c#f10#left#right
It means you want to intercept Ctrl+A, Ctrl+D, Alt+C, F10, Left and Right.
^#left
It means Ctrl+Left.
^#f1
It means Ctrl+F1.
@#f3
It means Alt+F3.

Note: it doesn't support Ctrl+Alt, Shift+Ctrl, Shift+Alt or Shift+Ctrl+Alt.

Specified by:
setCtrlKeys in interface XulElement
Throws:
UiException
Since:
3.0.6

getContext

public java.lang.String getContext()
Returns the ID of the popup (Popup) that should appear when the user right-clicks on the element (aka., context menu).

Default: null (no context menu).

Specified by:
getContext in interface XulElement

setContext

public void setContext(java.lang.String context)
Sets the ID of the popup (Popup) that should appear when the user right-clicks on the element (aka., context menu).

An onOpen event is sent to the context menu if it is going to appear. Therefore, developers can manipulate it dynamically (perhaps based on OpenEvent.getReference) by listening to the onOpen event.

Note: To simplify the use, it ignores the ID space when locating the component at the client. In other words, it searches for the first component with the specified ID, no matter it is in the same ID space or not.

(since 3.0.2) If there are two components with the same ID (of course, in different ID spaces), you can specify the UUID with the following format:
uuid(comp_uuid)

Example:


 <label context="some">
 <label context="uuid(${some.uuid})"/>
 
Both reference a component whose ID is "some". But, if there are several components with the same ID, the first one can reference to any of them. And, the second one reference to the component in the same ID space (of the label component).

Specified by:
setContext in interface XulElement
See Also:
setContext(Popup)

setContext

public void setContext(Popup popup)
Sets the UUID of the popup that should appear when the user right-clicks on the element (aka., context menu).

Note: it actually invokes setContext("uuid(" + popup.getUuid() + ")")

Specified by:
setContext in interface XulElement
Since:
3.0.2
See Also:
setContext(String)

getPopup

public java.lang.String getPopup()
Returns the ID of the popup (Popup) that should appear when the user clicks on the element.

Default: null (no poppup).

Specified by:
getPopup in interface XulElement

setPopup

public void setPopup(java.lang.String popup)
Sets the ID of the popup (Popup) that should appear when the user clicks on the element.

An onOpen event is sent to the popup menu if it is going to appear. Therefore, developers can manipulate it dynamically (perhaps based on OpenEvent.getReference) by listening to the onOpen event.

Note: To simplify the use, it ignores the ID space when locating the component at the client. In other words, it searches for the first component with the specified ID, no matter it is in the same ID space or not.

(since 3.0.2) If there are two components with the same ID (of course, in different ID spaces), you can specify the UUID with the following format:
uuid(comp_uuid)

Specified by:
setPopup in interface XulElement
See Also:
setPopup(Popup)

setPopup

public void setPopup(Popup popup)
Sets the UUID of the popup that should appear when the user clicks on the element.

Note: it actually invokes setPopup("uuid(" + popup.getUuid() + ")")

Specified by:
setPopup in interface XulElement
Since:
3.0.2
See Also:
setPopup(String)

getTooltip

public java.lang.String getTooltip()
Returns the ID of the popup (Popup) that should be used as a tooltip window when the mouse hovers over the element for a moment. The tooltip will automatically disappear when the mouse is moved.

Default: null (no tooltip).

Specified by:
getTooltip in interface XulElement

setTooltip

public void setTooltip(java.lang.String tooltip)
Sets the ID of the popup (Popup) that should be used as a tooltip window when the mouse hovers over the element for a moment.

An onOpen event is sent to the tooltip if it is going to appear. Therefore, developers can manipulate it dynamically (perhaps based on OpenEvent.getReference) by listening to the onOpen event.

Note: To simplify the use, it ignores the ID space when locating the component at the client. In other words, it searches for the first component with the specified ID, no matter it is in the same ID space or not.

(since 3.0.2) If there are two components with the same ID (of course, in different ID spaces), you can specify the UUID with the following format:
uuid(comp_uuid)

Specified by:
setTooltip in interface XulElement
See Also:
setTooltip(Popup)

setTooltip

public void setTooltip(Popup popup)
Sets the UUID of the popup that should be used as a tooltip window when the mouse hovers over the element for a moment.

Note: it actually invokes setTooltip("uuid(" + popup.getUuid() + ")")

Specified by:
setTooltip in interface XulElement
Since:
3.0.2
See Also:
setTooltip(String)

getAction

public java.lang.String getAction()
Returns the client-side action (CSA).

The format:
action1: javascript1; javascript2; action2: javascript3

You could specify any action as long as JavaScript supports, such as onfocus, onblur, onmouseover and onmousout.

Specified by:
getAction in interface XulElement

setAction

public void setAction(java.lang.String action)
Sets the client-side action.

Specified by:
setAction in interface XulElement

getActionAttrs

protected java.lang.String getActionAttrs()
Returns the HTML attributes representing the client-side action, or "" if no client-side action is defined. Used only for component development.

Override this method if you want to customize the generation of the client-side action (though rarely).

Since:
3.0.0

getAllOnClickAttrs

protected java.lang.String getAllOnClickAttrs(boolean ignoreOnClick)
Deprecated. As of release 3.0.5, replaced with HtmlBasedComponent.getAllOnClickAttrs(). If you want to generate only onDoubleClick and onRightClick, use

appendAsapAttr(sb, Events.ON_DOUBLE_CLICK);
appendAsapAttr(sb, Events.ON_RIGHT_CLICK);


getOuterAttrs

public java.lang.String getOuterAttrs()
Description copied from class: HtmlBasedComponent
Returns the exterior attributes for generating the enclosing HTML tag; never return null.

Used only by component developers.

Default: Generates the tooltip text, style, sclass, draggable and droppable attribute if necessary. In other words, the corresponding attribute is generated if HtmlBasedComponent.getTooltiptext(), HtmlBasedComponent.getRealStyle(), HtmlBasedComponent.getSclass(), HtmlBasedComponent.getDraggable(), HtmlBasedComponent.getDroppable() are defined.

You have to call both HtmlBasedComponent.getOuterAttrs() and HtmlBasedComponent.getInnerAttrs() to generate complete attributes.

For simple components that all attributes are put on the outest HTML element, all you need is as follows.

<xx id="${self.uuid}"${self.outerAttrs}${self.innerAttrs}>

If you want to put attributes in a nested HTML element, you shall use the following pattern. Notice: if HtmlBasedComponent.getInnerAttrs() in a different tag, the tag must be named with "${self.uuid}!real".

<xx id="${self.uuid}"${self.outerAttrs}>
 <yy id="${self.uuid}!real"${self.innerAttrs}>...

Note: This class handles non-deferrable event listeners automatically. However, you have to invoke AbstractComponent.appendAsapAttr(java.lang.StringBuffer, java.lang.String) for each event the component handles in HtmlBasedComponent.getOuterAttrs() as follows.


        appendAsapAttr(sb, Events.ON_OPEN);
  appendAsapAttr(sb, Events.ON_CHANGE);

Theorectically, you could put any attributes in either HtmlBasedComponent.getInnerAttrs() or HtmlBasedComponent.getOuterAttrs(). However, zkau.js assumes all attributes are put at the outer one. If you want something different, you have to provide your own setAttr (refer to how checkbox is implemented).

Overrides:
getOuterAttrs in class HtmlBasedComponent

getInnerAttrs

public java.lang.String getInnerAttrs()
Generates the Client-Side-Action attributes to the interior tag. Reason: onfocus is the main use.

Overrides:
getInnerAttrs in class HtmlBasedComponent


Copyright &copy; 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo