public class AbstractComponent extends java.lang.Object implements Component, ComponentCtrl, java.io.Serializable
Component.| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractComponent.Children
The default implementation for
getChildren(). |
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPEAFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE| Modifier | Constructor and Description |
|---|---|
|
AbstractComponent()
Constructs a component with auto-generated ID.
|
protected |
AbstractComponent(boolean useless)
Constructs a dummy component that is not associated
with any component definition.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAnnotation(java.lang.String annotName,
java.util.Map<java.lang.String,java.lang.String[]> annotAttrs)
Deprecated.
As of release 6.0.0, replaced with
addAnnotation(String, String, Map) |
void |
addAnnotation(java.lang.String propName,
java.lang.String annotName,
java.util.Map<java.lang.String,java.lang.String[]> annotAttrs)
Adds an annotation to the specified property of this component.
|
boolean |
addCallback(java.lang.String name,
Callback callback)
Adds a callback at component in specific name
|
protected static void |
addClientEvent(java.lang.Class<? extends Component> cls,
java.lang.String evtnm,
int flags)
Adds an event that the client might send to the server.
|
void |
addEventHandler(java.lang.String name,
EventHandler evthd)
Adds an event handler.
|
boolean |
addEventListener(int priority,
java.lang.String evtnm,
EventListener<? extends Event> listener)
Adds an event listener to specified event name for this component
with the given priority.
|
boolean |
addEventListener(java.lang.String evtnm,
EventListener<? extends Event> listener)
Adds an event listener to specified event name for this component.
|
boolean |
addForward(java.lang.String orgEvent,
Component target,
java.lang.String targetEvent)
Adds a forward condition to forward the event received
by this component to another component.
|
boolean |
addForward(java.lang.String orgEvent,
Component target,
java.lang.String targetEvent,
java.lang.Object eventData)
Adds a forward condition to forward the event received
by this component to another component with extra event data.
|
boolean |
addForward(java.lang.String orgEvent,
java.lang.String targetPath,
java.lang.String targetEvent)
Adds a forward condition to forward the event received
by this component to another component, specified with a path.
|
boolean |
addForward(java.lang.String orgEvent,
java.lang.String targetPath,
java.lang.String targetEvent,
java.lang.Object eventData)
Adds a forward condition to forward the event received
by this component to another component of the specified path
with extra event data.
|
protected void |
addMoved(Component oldparent,
Page oldpg,
Page newpg)
Called when this component is moved from the specified parent
and/or page to the new page.
|
boolean |
addRedrawCallback(Callback<ContentRenderer> callback)
Adds a callback at component redraw phase.
|
boolean |
addScopeListener(ScopeListener listener)
Adds a listener to listen whether this scope is changed.
|
boolean |
addShadowRoot(ShadowElement shadow)
Adds the given shadow root from this host.
|
boolean |
addShadowRootBefore(ShadowElement shadow,
ShadowElement insertBefore)
Adds the given shadow root from this host.
|
void |
addSharedEventHandlerMap(EventHandlerMap evthds)
Adds a map of event handlers which is shared by other components.
|
boolean |
appendChild(Component child)
Appends a child to the end of all children.
|
void |
applyProperties()
Initializes the properties (a.k.a. members)
based on what are defined in the component definition.
|
void |
beforeChildAdded(Component child,
Component insertBefore)
Default: does nothing.
|
void |
beforeChildRemoved(Component child)
Default: does nothing.
|
void |
beforeParentChanged(Component parent)
Default: If parent is null, execute the @Destroy method if any.
|
java.lang.Object |
clone()
Clones the component.
|
void |
detach()
Detaches this component such that it won't belong to any page.
|
protected void |
didActivate(java.util.Collection<?> c)
Utility to invoke
ComponentActivationListener.didActivate(org.zkoss.zk.ui.Component)
for each object in the collection. |
protected void |
didActivate(java.lang.Object o)
Utility to invoke
ComponentActivationListener.didActivate(org.zkoss.zk.ui.Component)
for the specified object. |
protected void |
didDeserialize(java.util.Collection c)
Utility to invoke
ComponentSerializationListener.didDeserialize(org.zkoss.zk.ui.Component)
for each object in the collection. |
protected void |
didDeserialize(java.lang.Object o)
Utility to invoke
ComponentSerializationListener.didDeserialize(org.zkoss.zk.ui.Component)
for the specified object. |
void |
disableBindingAnnotation()
Set to disable the component with binding annotation.
|
boolean |
disableClientUpdate(boolean disable)
Sets whether to disable the update of the client widgets of
this component and its descendants.
|
void |
enableBindingAnnotation()
Set to enable the component with binding annotation.
|
java.util.List<java.lang.String> |
getAnnotatedProperties()
Returns a read-only list of the name of properties that
are associated at least one annotation (never null).
|
java.util.List<java.lang.String> |
getAnnotatedPropertiesBy(java.lang.String annotName)
Returns a read-only list of the names of the properties
that are associated with the specified annotation (never null).
|
Annotation |
getAnnotation(java.lang.String annotName)
Deprecated.
As of release 6.0.0, replaced with
getAnnotation(String, String). |
Annotation |
getAnnotation(java.lang.String propName,
java.lang.String annotName)
Returns the annotation associated with the definition of the specified
property, or null if not available.
|
java.util.Collection<Annotation> |
getAnnotations()
Deprecated.
As of release 6.0.0, replaced with
getAnnotations(String). |
java.util.Collection<Annotation> |
getAnnotations(java.lang.String propName)
Returns a read-only collection of all annotations (
Annotation)
associated with the specified property. |
java.util.Collection<Annotation> |
getAnnotations(java.lang.String propName,
java.lang.String annotName)
Returns the annotations associated with the definition of the specified
property.
|
java.lang.Object |
getAttribute(java.lang.String name)
Returns the custom attribute associated with this component, i.e.,
Component.COMPONENT_SCOPE. |
java.lang.Object |
getAttribute(java.lang.String name,
boolean recurse)
Returns the custom attribute associated with this object.
|
java.lang.Object |
getAttribute(java.lang.String name,
int scope)
Returns the value of the specified custom attribute in the specified scope,
or null if not defined.
|
java.lang.Object |
getAttributeOrFellow(java.lang.String name,
boolean recurse)
Returns the custom attribute associated with this component,
or the fellow of this component; or null if not found.
|
java.util.Map<java.lang.String,java.lang.Object> |
getAttributes()
Returns all custom attributes associated with this component, i.e.,
Component.COMPONENT_SCOPE. |
java.util.Map<java.lang.String,java.lang.Object> |
getAttributes(int scope)
Returns all custom attributes of the specified scope.
|
AuService |
getAuService()
Returns an AU service to process the AU request before the component's
default handling.
|
java.lang.String |
getAutag()
Returns the AU tag for this widget.
|
java.util.Collection<Callback> |
getCallback(java.lang.String name)
Returns all of callbacks by specific name
|
<T extends Component> |
getChildren()
Returns a live list of children.
|
java.lang.String |
getClientAttribute(java.lang.String name)
Returns the value of a DOM attribute
|
java.lang.String |
getClientDataAttribute(java.lang.String name)
Returns the value of a DOM data attribute
Notice that the parameter - name would be expanded by adding the prefix
"data-" automatically.
|
java.util.Map<java.lang.String,java.lang.Integer> |
getClientEvents()
Returns a map of event information that the client might send to this component.
|
protected java.lang.String |
getDefaultMold(java.lang.Class<? extends Component> klass)
Returns the default mold for the given class.
|
ComponentDefinition |
getDefinition()
Returns the component definition of this component (never null).
|
Desktop |
getDesktop()
Returns the desktop of this component,
or null if this component doesn't belong to any desktop.
|
ZScript |
getEventHandler(java.lang.String evtnm)
Returns the event listener of the specified name, or null
if not found.
|
java.util.Set<java.lang.String> |
getEventHandlerNames()
Returns a readonly collection of event names (String), or
an empty collection if no event name is registered.
|
EventListenerMap |
getEventListenerMap()
Returns the map of event handlers and listeners defined in this component.
|
java.lang.Iterable<EventListener<? extends Event>> |
getEventListeners(java.lang.String evtnm)
Returns an iterable collection of the event listeners for the given event.
|
java.lang.Object |
getExtraCtrl()
Returns the extra controls that tell ZK how to handle this component
specially.
|
Component |
getFellow(java.lang.String compId)
Returns a component of the specified ID in the same ID space.
|
Component |
getFellow(java.lang.String compId,
boolean recurse)
Returns a component of the specified ID in the same ID space.
|
Component |
getFellowIfAny(java.lang.String compId)
Returns a component of the specified ID in the same ID space, or null
if not found.
|
Component |
getFellowIfAny(java.lang.String compId,
boolean recurse)
Returns a component of the specified ID in the same ID space, or null
if not found.
|
java.util.Collection<Component> |
getFellows()
Returns all fellows in the same ID space of this component.
|
Component |
getFirstChild()
Returns the first child component, or null if no child at all.
|
java.lang.String |
getId()
Returns the ID.
|
Component |
getLastChild()
Returns the last child component, or null if no child at all.
|
java.util.Iterator<EventListener<? extends Event>> |
getListenerIterator(java.lang.String evtnm)
Deprecated.
As of release 6.0, replaced with
getEventListeners(java.lang.String). |
java.lang.String |
getMold()
Returns the mold used to render this component.
|
Component |
getNextSibling()
Returns the next sibling, or null if it is the last child.
|
Page |
getPage()
Returns the page that this component belongs to, or null if
it doesn't belong to any page.
|
Component |
getParent()
Returns the parent component, or null if this is the root component.
|
Component |
getPreviousSibling()
Returns the previous sibling, or null if it is the first child.
|
PropertyAccess |
getPropertyAccess(java.lang.String prop)
Returns the corresponding property access object from the given property
name, if any.
|
java.util.Collection<Callback<ContentRenderer>> |
getRedrawCallback()
Returns all of callbacks for component redraw phase
|
Component |
getRoot()
Returns the root of the specified component.
|
ShadowElement |
getShadowFellowIfAny(java.lang.String id)
Returns the shadow element under this shadow host.
|
<T extends ShadowElement> |
getShadowRoots()
Returns a set of shadow elements, if any.
|
java.lang.Object |
getShadowVariable(Component baseChild,
java.lang.String name,
boolean recurse)
Returns the shadow variable enclosed with the base component, which
associated with this component or its parent component; or null if not found.
|
java.lang.Object |
getShadowVariable(java.lang.String name,
boolean recurse)
Returns the shadow variable associated with this component or its parent
component; or null if not found.
|
protected java.lang.Object |
getShadowVariable0(Component baseChild,
java.lang.String name,
boolean recurse) |
IdSpace |
getSpaceOwner()
Returns the owner of the ID space that this component belongs to.
|
protected java.lang.String |
getSpecialRendererOutput(Component comp) |
java.lang.String |
getStubonly()
Returns whether this component is stub-only.
|
int |
getSubBindingAnnotationCount()
Returns the count of the component's subtree binding annotation.
|
Template |
getTemplate(java.lang.String name)
Returns the template of the given name, or null if not available.
|
java.util.Set<java.lang.String> |
getTemplateNames()
Returns a readonly set of the names of all templates.
|
java.lang.String |
getUuid()
Returns UUID (universal unique ID) which is unique in the whole
session.
|
java.lang.String |
getWidgetAttribute(java.lang.String name) |
java.util.Set<java.lang.String> |
getWidgetAttributeNames()
Returns a read-only collection of additions DOM attributes that shall be
generated.
|
java.lang.String |
getWidgetClass()
Returns the widget class (a.k.a., widget type), or null if not defined.
|
java.lang.String |
getWidgetListener(java.lang.String evtnm)
Returns the script of the client event, or null if not found.
|
java.util.Set<java.lang.String> |
getWidgetListenerNames()
Returns a read-only collection of event names (String) that
the listener of the peer widget are assigned, or
an empty collection if none is registered.
|
java.lang.String |
getWidgetOverride(java.lang.String name)
Returns the script of the method definition to override
widget's method, or null if not found.
|
java.util.Set<java.lang.String> |
getWidgetOverrideNames()
Returns a read-only collection of the property names (String) that
shall be overridden, or an empty collection if none is registered.
|
boolean |
hasAttribute(java.lang.String name)
Returns if the custom attribute is associate with this component.
|
boolean |
hasAttribute(java.lang.String name,
boolean recurse)
Returns if a custom attribute is associated with this object.
|
boolean |
hasAttribute(java.lang.String name,
int scope)
Returns if the custom attribute is associate with this component.
|
boolean |
hasAttributeOrFellow(java.lang.String name,
boolean recurse)
Returns if a custom attribute is associated with this component,
or the fellow of this component.
|
boolean |
hasBindingAnnotation()
Returns whether the component itself has binding annotation or not.
|
boolean |
hasFellow(java.lang.String compId)
Returns whether a fellow exists in the same ID space of this component.
|
boolean |
hasFellow(java.lang.String compId,
boolean recurse)
Returns whether there is a fellow named with the specified component ID
in the same ID space as this component.
|
boolean |
hasSubBindingAnnotation()
Returns whether the component and its children have binding annotation or not.
|
boolean |
insertBefore(Component newChild,
Component refChild)
Inserts a child before the reference child.
|
void |
invalidate()
Invalidates this component by setting the dirty flag
such that it will be redraw the whole content of this
component and its dependencies later.
|
void |
invalidatePartial()
Invalidates this component by setting the dirty flag
such that it will be redraw the partial content of this
component and its dependencies later.
|
protected boolean |
isChildable()
Returns whether this component can have a child.
|
boolean |
isInitialized()
Returns if it's finished layout phase (initializing).
|
boolean |
isInvalidated()
Returns if this component needs to be redrawn at the client.
|
boolean |
isListenerAvailable(java.lang.String evtnm,
boolean asap)
Returns whether the event listener is available.
|
boolean |
isVisible()
Returns whether this component is visible.
|
void |
onChildAdded(Component child)
Default: handles special event listeners.
|
void |
onChildRemoved(Component child)
Default: handles special event listeners.
|
void |
onPageAttached(Page newpage,
Page oldpage)
Default: handles special event listeners.
|
void |
onPageDetached(Page page)
Default: handles special event listeners.
|
WrongValueException |
onWrongValue(WrongValueException ex)
Notifies that an
WrongValueException instance is thrown,
and WrongValueException.getComponent() is this component. |
Component |
query(java.lang.String selector)
Find the first component that matches the given CSS3 selector.
|
java.lang.Iterable<Component> |
queryAll(java.lang.String selector)
Returns an iterable object for components that match the given CSS3 selector.
|
void |
redraw(java.io.Writer out)
Redraws this component and all its descendants.
|
protected void |
redrawChildren(java.io.Writer out)
Redraws children (and then recursively descendants).
|
java.lang.Object |
removeAttribute(java.lang.String name)
Removes the custom attribute associated with this component, i.e.,
Component.COMPONENT_SCOPE. |
java.lang.Object |
removeAttribute(java.lang.String name,
boolean recurse)
Removes the custom attribute associated with this scope.
|
java.lang.Object |
removeAttribute(java.lang.String name,
int scope)
Removes the specified custom attribute in the specified scope.
|
boolean |
removeCallback(java.lang.String name,
Callback callback)
Removes a callback for component by specific name.
|
boolean |
removeChild(Component child)
Removes a child.
|
boolean |
removeEventListener(java.lang.String evtnm,
EventListener<? extends Event> listener)
Removes an event listener.
|
boolean |
removeForward(java.lang.String orgEvent,
Component target,
java.lang.String targetEvent)
Removes a forward condition that was added by
Component.addForward(String, Component, String). |
boolean |
removeForward(java.lang.String orgEvent,
java.lang.String targetPath,
java.lang.String targetEvent)
Removes a forward condition that was added by
Component.addForward(String, String, String). |
boolean |
removeRedrawCallback(Callback<ContentRenderer> callback)
Removes a callback for component redraw phase.
|
boolean |
removeScopeListener(ScopeListener listener)
Removes a change listener from this scope.
|
boolean |
removeShadowRoot(ShadowElement shadow)
Removes the given shadow root from this host.
|
protected void |
render(ContentRenderer renderer,
java.lang.String name,
boolean value)
An utility to be called by
renderProperties(org.zkoss.zk.ui.sys.ContentRenderer) to
render a boolean-value property if it is true. |
protected void |
render(ContentRenderer renderer,
java.lang.String name,
java.lang.Object value)
An utility to be called by
renderProperties(org.zkoss.zk.ui.sys.ContentRenderer) to
render a string-value property. |
protected void |
render(ContentRenderer renderer,
java.lang.String name,
java.lang.String value)
An utility to be called by
renderProperties(org.zkoss.zk.ui.sys.ContentRenderer) to
render a string-value property. |
protected void |
renderProperties(ContentRenderer renderer)
Called by (
ComponentCtrl.redraw(java.io.Writer)) to render the
properties, excluding the enclosing tag and children. |
protected void |
replace(Component comp,
boolean bFellow,
boolean bListener,
boolean bChildren)
Replace the specified component with this component in
the component tree.
|
protected void |
response(AuResponse response)
Causes a response to be sent to the client.
|
protected void |
response(java.lang.String key,
AuResponse response)
Causes a response to be sent to the client by overriding the key
returned by
AuResponse.getOverrideKey()). |
protected void |
response(java.lang.String key,
AuResponse response,
int priority)
Causes a response to be sent to the client by overriding the key
returned by
AuResponse.getOverrideKey()). |
void |
service(AuRequest request,
boolean everError)
Handles an AU request.
|
void |
service(Event event,
Scope scope)
Handles an event.
|
void |
sessionDidActivate(Page page)
Notification that the session, which owns this component,
has just been activated (a.k.a., deserialized).
|
void |
sessionWillPassivate(Page page)
Notification that the session, which owns this component,
is about to be passivated (a.k.a., serialized).
|
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets the custom attribute associated with this component, i.e.,
Component.COMPONENT_SCOPE. |
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object value,
boolean recurse)
Sets the custom attribute associated with this scope, or the parent
scope.
|
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object value,
int scope)
Sets the value of the specified custom attribute in the specified scope.
|
void |
setAuService(AuService ausvc)
Sets an AU service to process the AU request before the component's
default handling.
|
void |
setAutag(java.lang.String tag)
Sets the AU tag for this widget.
|
java.lang.String |
setClientAttribute(java.lang.String name,
java.lang.String value)
Sets or removes a DOM attribute of the peer widget (at the client).
|
java.lang.String |
setClientDataAttribute(java.lang.String name,
java.lang.String value)
Sets a DOM data attribute of the peer widget (at the client).
|
void |
setDefinition(ComponentDefinition compdef)
Sets the component definition.
|
void |
setDefinition(java.lang.String name)
Sets the component definition by specifying the name.
|
void |
setId(java.lang.String id)
Sets the ID.
|
void |
setMold(java.lang.String mold)
Sets the mold to render this component.
|
void |
setPage(Page page)
Sets what page this component belongs to.
|
void |
setPageBefore(Page page,
Component refRoot)
Sets what page this component belongs to, and insert
this component right before the reference component.
|
void |
setParent(Component parent)
Sets the parent component.
|
void |
setStubonly(boolean stubonly)
Sets whether this component is stub-only.
|
void |
setStubonly(java.lang.String stubonly)
Sets whether this component is stub-only.
|
protected void |
setSubBindingAnnotationCount(int diff,
AbstractComponent node) |
Template |
setTemplate(java.lang.String name,
Template template)
Sets a UI template which could be retrieved later
with
Component.getTemplate(java.lang.String). |
boolean |
setVisible(boolean visible)
Sets whether this component is visible.
|
protected void |
setVisibleDirectly(boolean visible)
Changes the visibility directly without sending any update to the client.
|
java.lang.String |
setWidgetAttribute(java.lang.String name,
java.lang.String value) |
void |
setWidgetClass(java.lang.String wgtcls)
Sets the widget class (a.k.a., the widget type).
|
java.lang.String |
setWidgetListener(java.lang.String evtnm,
java.lang.String script)
Sets or removes an event listener of the peer widget.
|
java.lang.String |
setWidgetOverride(java.lang.String name,
java.lang.String script)
Sets or removes a method or a property of the peer widget (at the client).
|
protected void |
smartUpdate(java.lang.String attr,
boolean value)
A special smart update to update a value in boolean.
|
protected void |
smartUpdate(java.lang.String attr,
byte value)
A special smart update to update a value in byte.
|
protected void |
smartUpdate(java.lang.String attr,
char value)
A special smart update to update a value in character.
|
protected void |
smartUpdate(java.lang.String attr,
double value)
A special smart update to update a value in double.
|
protected void |
smartUpdate(java.lang.String attr,
float value)
A special smart update to update a value in float.
|
protected void |
smartUpdate(java.lang.String attr,
int value)
A special smart update to update a value in int.
|
protected void |
smartUpdate(java.lang.String attr,
long value)
A special smart update to update a value in long.
|
protected void |
smartUpdate(java.lang.String attr,
java.lang.Object value)
Smart-updates a property of the peer widget associated with
the component, running at the client, with the given value.
|
protected void |
smartUpdate(java.lang.String attr,
java.lang.Object value,
boolean append)
Smart-updates a property of the peer widget with the given value
that allows caller to decide whether to append or overwrite.
|
protected void |
smartUpdateWidgetListener(java.lang.String evtnm,
java.lang.String script)
A special smart update to update an event listener for the
peer widget.
|
protected void |
smartUpdateWidgetOverride(java.lang.String name,
java.lang.String script)
A special smart update to update a method or a field of the peer widget.
|
java.lang.String |
toString() |
protected void |
updateByClient(java.lang.String name,
java.lang.Object value)
Called when the widget running at the client asks the server
to update a value.
|
protected void |
updateSubBindingAnnotationCount(int diff) |
protected void |
willPassivate(java.util.Collection<?> c)
Utility to invoke
ComponentActivationListener.willPassivate(org.zkoss.zk.ui.Component)
for each object in the collection. |
protected void |
willPassivate(java.lang.Object o)
Utility to invoke
ComponentActivationListener.willPassivate(org.zkoss.zk.ui.Component)
for the specified object. |
protected void |
willSerialize(java.util.Collection c)
Utility to invoke
ComponentSerializationListener.willSerialize(org.zkoss.zk.ui.Component)
for each object in the collection. |
protected void |
willSerialize(java.lang.Object o)
Utility to invoke
ComponentSerializationListener.willSerialize(org.zkoss.zk.ui.Component)
for the specified object. |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitinvalidatePartialpublic AbstractComponent()
protected AbstractComponent(boolean useless)
useless - an useless argument (it is ignored but used
to distinguish the default constructor)public Page getPage()
ComponentWhen a component is created (a.k.a., constructed), it doesn't belong to any page. And, if a component doesn't belong to any page, they won't be displayed at the client.
When changing parent (Component.setParent(org.zkoss.zk.ui.Component)), the child component's
page will become the same as parent's. In other words, a component
is added to a page automatically if it becomes a child of
another component (who belongs to a page).
For root components, you have to invoke Component.setPage(org.zkoss.zk.ui.Page)
Explicitly.
getPage in interface ComponentComponent.setParent(org.zkoss.zk.ui.Component),
Component.setPage(org.zkoss.zk.ui.Page)public Desktop getDesktop()
ComponentWhen a component is created in an event listener, it
is assigned to the current desktop automatically.
If a component is created not in any event listener, it doesn't
belong to any desktop and this method returns null.
Once a component is attached to a desktop (by use of Component.setPage(org.zkoss.zk.ui.Page)
or Component.setParent(org.zkoss.zk.ui.Component)), it belongs to the desktop.
Notice: there is no way to detach a component from a desktop, once it is attached as described above. In other words, you cannot move a component (or page) from one desktop to another.
In summary, there are only two ways to handle components.
getDesktop in interface Componentpublic void setPage(Page page)
ComponentFor child components, the page they belong is maintained automatically. You need to invoke this method only for root components.
Note: a component might be attached to a page due invocations
other than this method. For example, a component is attached
if its parent is attached.
To know whether it is attached, override
ComponentCtrl.onPageAttached(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Page)
rather than this method.
If you would like to monitor if a component is attached or detached
from a page, you could register a desktop listener implementing
UiLifeCycle.
setPage in interface ComponentComponentCtrl.onPageAttached(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Page),
ComponentCtrl.onPageDetached(org.zkoss.zk.ui.Page)public void setPageBefore(Page page, Component refRoot)
ComponentFor child components, the page they belong is maintained automatically. You need to invoke this method only for root components.
It is similar to Component.setPage(org.zkoss.zk.ui.Page), except this component
will be placed before the reference component.
If the reference component is null, this component is placed
at the end of all root components.
setPageBefore in interface ComponentrefRoot - another root component used as a reference
which this component will be placed before.
If null, this component will be placed at the end of all
root components (no matter whether it already belongs to the same page).Component.setPage(org.zkoss.zk.ui.Page)protected void addMoved(Component oldparent, Page oldpg, Page newpg)
Default: it notifies UiEngine to update the component
at the client (usually remove-and-add).
It is designed to let derived classes overriding this method to disable this update. However, you rarely need to override it. One possible but rare case: the component's visual part at the client updates the visual representation at the client and then notify the component at the server to update its children accordingly. In this case, it is redundant if we ask UI Engine to send the updates to client.
oldparent - the parent before moved.
The new parent can be found by calling getParent().oldpg - the parent before moved.newpg - the new page. getPage() might return
the old page.public java.lang.String getId()
ComponentDefault: "" (an empty string; it means no ID at all).
If a component belongs to an ID space (see IdSpace),
the ID must also be unique in the ID space it belongs.
any its parent and ancestor implements IdSpace.
If it is a root component (i.e., without any parent),
its ID must be unique among root components of the same page.
A page itself is also an ID space, so you could retrieve
components in a page by use of IdSpace.getFellow(java.lang.String), unless
the component is a descendant of another component that implements
IdSpace. In this case, you have to retrieve the parent
first (by use of IdSpace.getFellow(java.lang.String) and then use Component.getFellow(java.lang.String)
against the owner of the ID space.
In zscript and EL, a component with explicit ID can be accessed directly by the ID.
public void setId(java.lang.String id)
ComponentComponent.getId() for more details.
Default: "" (an empty string; it means no ID at all).
public java.lang.String getUuid()
ComponentRawId is also implemented.
It is mainly used for communication between client and server and you rarely need to access it.
If RawId is implemented as part of
a component, UUID is the same as Component.getId() if Component.setId(java.lang.String)
is ever called. It is designed to migrate HTML pages to ZK, such
that the element ID could remain the same.
public IdSpace getSpaceOwner()
ComponentIdSpace, this method
returns itself.
If it has an ancestor that implements IdSpace,
the ancestor is returned.
Otherwise, the page it belongs to is returned
Each ID space defines an independent set of IDs. No component
in the same ID space could have the same ID.
To get any component in the same ID space, you could use
Component.getFellow(java.lang.String).
See IdSpace for more details.
The ID space related methods include Component.getFellow(java.lang.String),
Component.getAttribute(java.lang.String, int) and Component.getAttributeOrFellow(java.lang.String, boolean).
getSpaceOwner in interface Componentpublic boolean hasFellow(java.lang.String compId)
Componentpublic boolean hasFellow(java.lang.String compId,
boolean recurse)
Componentpublic Component getFellow(java.lang.String compId) throws ComponentNotFoundException
ComponentUnlike Component.getFellowIfAny(java.lang.String), it throws an exception if not found.
getFellow in interface ComponentComponentNotFoundException - is thrown if fellow not foundpublic Component getFellow(java.lang.String compId, boolean recurse) throws ComponentNotFoundException
ComponentUnlike Component.getFellowIfAny(String, boolean), it throws ComponentNotFoundException
if not found.
getFellow in interface Componentrecurse - whether to look up the parent ID space for the
existence of the fellowComponentNotFoundException - is thrown if
this component doesn't belong to any ID spacepublic Component getFellowIfAny(java.lang.String compId)
ComponentUnlike Component.getFellow(java.lang.String), it returns null if not found.
getFellowIfAny in interface Componentpublic Component getFellowIfAny(java.lang.String compId, boolean recurse)
ComponentUnlike Component.getFellow(String, boolean), it returns null
if not found.
getFellowIfAny in interface Componentrecurse - whether to look up the parent ID space for the
existence of the fellowpublic java.util.Collection<Component> getFellows()
ComponentgetFellows in interface Componentpublic Component getNextSibling()
ComponentgetNextSibling in interface Componentpublic Component getPreviousSibling()
ComponentgetPreviousSibling in interface Componentpublic Component getFirstChild()
ComponentgetFirstChild in interface Componentpublic Component getLastChild()
ComponentgetLastChild in interface Componentpublic java.lang.String setWidgetListener(java.lang.String evtnm,
java.lang.String script)
ComponentsetWidgetListener in interface Componentevtnm - the event name, such as onClickscript - the script to handle the event. If null, the event
handler is removed.public java.lang.String getWidgetListener(java.lang.String evtnm)
ComponentgetWidgetListener in interface Componentpublic java.util.Set<java.lang.String> getWidgetListenerNames()
ComponentgetWidgetListenerNames in interface Componentpublic java.lang.String setWidgetOverride(java.lang.String name,
java.lang.String script)
ComponentFor example,
comp.setWidgetOverride("setValue", "function (value) {}"); //override a method
comp.setWidgetOverride("myfield", "new Date()"); //override a property
If there is no previous method or property, the method/property will be assigned directly.
Notice that, unlike Component.setWidgetListener(java.lang.String, java.lang.String), if the method has been sent
to the client for update, it cannot be removed by calling this method
with a null value.
In other words, invoking this method with a null value only removes
the method overrides if it has not YET been to sent to the client.
The previous method/property can be accessed by this.$xxx. For example
function (value, fromServer) {
this.$setValue(value, fromServer);
if (this.desktop) {
this._cnt = !this._cnt;
this.setStyle('background:'+(this._cnt ? 'red':'green'));
}
}
Notice that, since it is not extending, so this.$super references the superclass's method, rather than the old method.
setWidgetOverride in interface Componentname - the property name to override,
such as setValue and miles.script - the method definition, such as function (arg) {...},
or a value, such as 123 and new Date().
If not null, this method will be added to the peer widget.
If there was a method with the same name, it will be renamed to
$name so can you call it back.
<label w:setValue="function (value) {
this.$setValue(value); //old method
}"/>
If null, the previous method, if any, will be restored.public java.lang.String getWidgetOverride(java.lang.String name)
ComponentgetWidgetOverride in interface Componentpublic java.util.Set<java.lang.String> getWidgetOverrideNames()
ComponentgetWidgetOverrideNames in interface Componentpublic java.lang.String setWidgetAttribute(java.lang.String name,
java.lang.String value)
setWidgetAttribute in interface Componentpublic java.lang.String setClientAttribute(java.lang.String name,
java.lang.String value)
ComponentNotice that Component.setWidgetOverride(java.lang.String, java.lang.String) or Component.setWidgetListener(java.lang.String, java.lang.String)
are used to customize the peer widget, while Component.setWidgetAttribute(java.lang.String, java.lang.String)
customizes the DOM element of the peer widget directly.
Unlike Component.setWidgetOverride(java.lang.String, java.lang.String) or Component.setWidgetListener(java.lang.String, java.lang.String),
Component.setWidgetAttribute(java.lang.String, java.lang.String) has no effect if the widget has been
generated at the client, unless Component.invalidate() is called.
setClientAttribute in interface Componentname - the attribute name to generate to the DOM element,
such as onload.
Unlike Component.setWidgetOverride(java.lang.String, java.lang.String), the name might contain
no alphanumeric characters, such as colon and dash.value - the value of the attribute. It could be anything
depending on the attribute.
If null, the attribute will be removed. Make sure to specify an empty
string if you want an attribute with an empty value.public java.lang.String getWidgetAttribute(java.lang.String name)
getWidgetAttribute in interface Componentpublic java.lang.String getClientAttribute(java.lang.String name)
ComponentgetClientAttribute in interface Componentpublic java.util.Set<java.lang.String> getWidgetAttributeNames()
ComponentComponent.setWidgetAttribute(java.lang.String, java.lang.String).getWidgetAttributeNames in interface Componentpublic java.lang.String setClientDataAttribute(java.lang.String name,
java.lang.String value)
ComponentNotice that the parameter - name would be expanded by adding the prefix "data-" automatically.
setClientDataAttribute in interface Componentname - the attribute name to generate to the DOM element,
such as mask.value - the value of the attribute. It could be anything
depending on the attribute.
If null, the attribute will be removed. Make sure to specify an empty
string if you want an attribute with an empty value.Component.setClientDataAttribute(String, String)public java.lang.String getClientDataAttribute(java.lang.String name)
ComponentNotice that the parameter - name would be expanded by adding the prefix "data-" automatically.
getClientDataAttribute in interface ComponentComponent.getClientDataAttribute(String)public java.util.Map<java.lang.String,java.lang.Object> getAttributes(int scope)
ComponentIf scope is Component.COMPONENT_SCOPE, it means custom attributes private
to this component.
If scope is Component.SPACE_SCOPE, it means custom attributes shared
by components from the same ID space as this one's.
If scope is Component.PAGE_SCOPE, it means custom attributes shared
by components from the same page as this one's.
If scope is Component.DESKTOP_SCOPE, it means custom attributes shared
by components from the same desktops this one's.
getAttributes in interface Componentscope - one of Component.COMPONENT_SCOPE, Component.SPACE_SCOPE,
Component.PAGE_SCOPE, Component.DESKTOP_SCOPE, Component.SESSION_SCOPE,
Component.REQUEST_SCOPE or Component.APPLICATION_SCOPE,public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
ComponentComponent.COMPONENT_SCOPE.getAttributes in interface ComponentgetAttributes in interface Scopepublic java.lang.Object getAttribute(java.lang.String name,
int scope)
ComponentIf scope is Component.COMPONENT_SCOPE, it means attributes private
to this component.
If scope is Component.SPACE_SCOPE, it means custom attributes shared
by components from the same ID space as this one's.
If scope is Component.PAGE_SCOPE, it means custom attributes shared
by components from the same page as this one's.
If scope is Component.DESKTOP_SCOPE, it means custom attributes shared
by components from the same desktop as this one's.
getAttribute in interface Componentscope - one of Component.COMPONENT_SCOPE, Component.SPACE_SCOPE,
Component.PAGE_SCOPE, Component.DESKTOP_SCOPE, Component.SESSION_SCOPE,
Component.REQUEST_SCOPE or Component.APPLICATION_SCOPE,public java.lang.Object getAttribute(java.lang.String name)
ComponentComponent.COMPONENT_SCOPE.getAttribute in interface ComponentgetAttribute in interface Scopepublic java.lang.Object getAttribute(java.lang.String name,
boolean recurse)
ScopegetAttribute in interface Scoperecurse - whether to search its ancestor scope.
If true and the current scope doen't define the attribute,
it searches up its ancestor to see
any of them has defined the specified attribute.public boolean hasAttribute(java.lang.String name,
int scope)
ComponentIf scope is Component.COMPONENT_SCOPE, it means attributes private
to this component.
If scope is Component.SPACE_SCOPE, it means custom attributes shared
by components from the same ID space as this one's.
If scope is Component.PAGE_SCOPE, it means custom attributes shared
by components from the same page as this one's.
If scope is Component.DESKTOP_SCOPE, it means custom attributes shared
by components from the same desktop as this one's.
Notice that null is a valid value, so you can
tell if an attribute is associated by examining the return value
of Component.getAttribute(java.lang.String, int).
hasAttribute in interface Componentscope - one of Component.COMPONENT_SCOPE, Component.SPACE_SCOPE,
Component.PAGE_SCOPE, Component.DESKTOP_SCOPE, Component.SESSION_SCOPE,
Component.REQUEST_SCOPE or Component.APPLICATION_SCOPE,public boolean hasAttribute(java.lang.String name)
ComponentNotice that null is a valid value, so you can
tell if an attribute is associated by examining the return value
of Component.getAttribute(java.lang.String, int).
hasAttribute in interface ComponenthasAttribute in interface Scopepublic boolean hasAttribute(java.lang.String name,
boolean recurse)
ScopeNotice that null is a valid value, so you can
tell if an attribute is associated by examining the return value
of Scope.getAttribute(java.lang.String).
hasAttribute in interface Scoperecurse - whether to search its ancestor scope.
If true and the current scope doen't define the attribute,
it searches up its ancestor to see
any of them has defined the specified attribute.public java.lang.Object setAttribute(java.lang.String name,
java.lang.Object value,
int scope)
ComponentNote: The attribute is removed (by Component.removeAttribute(java.lang.String, int)
if value is null.
If scope is Component.COMPONENT_SCOPE, it means custom attributes private
to this component.
If scope is Component.SPACE_SCOPE, it means custom attributes shared
by components from the same ID space as this one's.
If scope is Component.PAGE_SCOPE, it means custom attributes shared
by components from the same page as this one's.
If scope is Component.DESKTOP_SCOPE, it means custom attributes shared
by components from the same desktop as this one's.
setAttribute in interface Componentvalue - the value. If null, the attribute is removed.scope - one of Component.COMPONENT_SCOPE, Component.SPACE_SCOPE,
Component.PAGE_SCOPE, Component.DESKTOP_SCOPE, Component.SESSION_SCOPE,
Component.REQUEST_SCOPE or Component.APPLICATION_SCOPE,public java.lang.Object setAttribute(java.lang.String name,
java.lang.Object value)
ComponentComponent.COMPONENT_SCOPE.setAttribute in interface ComponentsetAttribute in interface Scopepublic java.lang.Object setAttribute(java.lang.String name,
java.lang.Object value,
boolean recurse)
ScopesetAttribute in interface Scoperecurse - whether to look up the parent scope for the
existence of the attribute.Scope.setAttribute(String,Object).public java.lang.Object removeAttribute(java.lang.String name,
int scope)
ComponentIf scope is Component.COMPONENT_SCOPE, it means attributes private
to this component.
If scope is Component.SPACE_SCOPE, it means custom attributes shared
by components from the same ID space as this one's.
If scope is Component.PAGE_SCOPE, it means custom attributes shared
by components from the same page as this one's.
If scope is Component.DESKTOP_SCOPE, it means custom attributes shared
by components from the same desktop as this one's.
removeAttribute in interface Componentscope - Component.COMPONENT_SCOPE, Component.SPACE_SCOPE,
Component.PAGE_SCOPE, Component.DESKTOP_SCOPE, Component.SESSION_SCOPE,
Component.REQUEST_SCOPE or Component.APPLICATION_SCOPE,public java.lang.Object removeAttribute(java.lang.String name)
ComponentComponent.COMPONENT_SCOPE.removeAttribute in interface ComponentremoveAttribute in interface Scopepublic java.lang.Object removeAttribute(java.lang.String name,
boolean recurse)
ScoperemoveAttribute in interface Scoperecurse - whether to look up the parent scope for the
existence of the attribute.Scope.removeAttribute(String).public java.lang.Object getAttributeOrFellow(java.lang.String name,
boolean recurse)
ComponentNotice that it doesn't check any variable defined in
VariableResolver
(of Page.addVariableResolver(org.zkoss.xel.VariableResolver)).
getAttributeOrFellow in interface Componentrecurse - whether to look up the parent component for the
existence of the attribute.public java.lang.Object getShadowVariable(java.lang.String name,
boolean recurse)
ComponentNotice that it doesn't check any variable defined in
VariableResolver
(of Page.addVariableResolver(org.zkoss.xel.VariableResolver)).
getShadowVariable in interface Componentrecurse - whether to look up the parent component for the
existence of the shadow variable.public java.lang.Object getShadowVariable(Component baseChild, java.lang.String name, boolean recurse)
ComponentNotice that it doesn't check any variable defined in
VariableResolver
(of Page.addVariableResolver(org.zkoss.xel.VariableResolver)).
getShadowVariable in interface ComponentbaseChild - the base component to seek the variable.recurse - whether to look up the parent component for the
existence of the shadow variable.Component.getShadowVariable(String, boolean)protected java.lang.Object getShadowVariable0(Component baseChild, java.lang.String name, boolean recurse)
public boolean hasAttributeOrFellow(java.lang.String name,
boolean recurse)
ComponentNotice that it doesn't check any variable defined in
VariableResolver
(of Page.addVariableResolver(org.zkoss.xel.VariableResolver)).
hasAttributeOrFellow in interface Componentrecurse - whether to look up the parent component for the
existence of the attribute.public boolean addScopeListener(ScopeListener listener)
ScopeaddScopeListener in interface Scopepublic boolean removeScopeListener(ScopeListener listener)
ScoperemoveScopeListener in interface Scopepublic java.lang.String getAutag()
Componentxxx,yyy and the desktop's
request path (Desktop.getRequestPath()) is /foo.zul, then
the URL of the AU request will contain /_/foo.zul/xxx,yyy,.
Default: null (no AU tag for this widget).
getAutag in interface ComponentComponent.setAutag(java.lang.String)public void setAutag(java.lang.String tag)
ComponentsetAutag in interface Componenttag - the AU tag. Both an empty string and null are considered as null,
i.e., no AU tag for this widget.Component.getAutag()public Component getParent()
Componentpublic void setParent(Component parent)
ComponentNote: Component.setParent(org.zkoss.zk.ui.Component) always calls back Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)
and/or Component.removeChild(org.zkoss.zk.ui.Component),
while Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component) and Component.removeChild(org.zkoss.zk.ui.Component)
always calls back Component.setParent(org.zkoss.zk.ui.Component),
if the parent is changed. Thus, you don't need to override
both Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component) and Component.setParent(org.zkoss.zk.ui.Component), if you want
to customize the behavior.
public boolean insertBefore(Component newChild, Component refChild)
ComponentYou could use Component.setParent(org.zkoss.zk.ui.Component) or Component.appendChild(org.zkoss.zk.ui.Component)
instead of this method, unless
you want to control where to put the child.
Note: Component.setParent(org.zkoss.zk.ui.Component) always calls back Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)
and/or Component.removeChild(org.zkoss.zk.ui.Component),
while Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component) and Component.removeChild(org.zkoss.zk.ui.Component)
always calls back Component.setParent(org.zkoss.zk.ui.Component),
if the parent is changed. Thus, you don't need to override
both Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component) and Component.setParent(org.zkoss.zk.ui.Component), if you want
to customize the behavior.
If you would like to monitor if a component is attached or detached
from a page, you could register a desktop listener implementing
UiLifeCycle.
insertBefore in interface ComponentnewChild - the new child to be inserted.refChild - the child before which you want the new child
being inserted. If null, the new child is append to the end.protected void replace(Component comp, boolean bFellow, boolean bListener, boolean bChildren)
Notice that the replacement won't change anything at the client. It is the caller'job to maintain the consistency between the server and the client.
This method is rarely used.
comp - the component. In this implementation it supports
only derived classes of AbstractComponent.bFellow - whether to add this component to the map of fellows
if it is assigned with an ID. If false, the component (comp) cannot
be retrieved back even with an ID (note: ID is always preserved).bListener - whether to retain the event listeners and handlers.
If true, the event listeners and handlers, if any, will be registered
to this stub component. In other words, the event will be processed.
However, it is a stub component, rather than the original one.
I means the event is the most generic format: an instance of
Event (rather than MouseEvent or others).bChildren - whether to have the children of the given component.java.lang.IllegalStateException - if this component has a parent,
sibling or child.public boolean appendChild(Component child)
insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component) with refChild to be null.
Derives cannot override this method, and they shall override
insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component) instead.appendChild in interface ComponentComponent.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)public boolean removeChild(Component child)
ComponentComponent.detach()) and it will be removed
if it is no longer used.
You could use Component.setParent(org.zkoss.zk.ui.Component) with null instead of this method.
Note: Component.setParent(org.zkoss.zk.ui.Component) always calls back Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)
and/or Component.removeChild(org.zkoss.zk.ui.Component),
while Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component) and Component.removeChild(org.zkoss.zk.ui.Component)
always calls back Component.setParent(org.zkoss.zk.ui.Component),
if the parent is changed. Thus, you don't need to override
both Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component) and Component.setParent(org.zkoss.zk.ui.Component), if you want
to customize the behavior.
If you would like to monitor if a component is attached or detached
from a page, you could register a desktop listener implementing
UiLifeCycle.
removeChild in interface Componentprotected boolean isChildable()
Default: return true (means it can have children).
public <T extends Component> java.util.List<T> getChildren()
Default: instantiates and returns an instance of AbstractComponent.Children.
getChildren in interface Componentpublic Component getRoot()
public boolean isVisible()
ComponentisVisible in interface ComponentComponents.isRealVisible(org.zkoss.zk.ui.Component),
Component.setVisible(boolean)public boolean setVisible(boolean visible)
Componentdisplay:none. Since a DOM element will inherit its parent's CSS rules, a component is visible only if all of its parents are also visible.Component.detach().setVisible in interface Componentprotected void setVisibleDirectly(boolean visible)
setVisible(boolean) instead.public java.lang.String getStubonly()
ComponentThere are three possible values: "true", "false", and "inherit", and "ignore-native".
Notice that the native components will be stub-ized, no matter
this property is set. Though rarely required, you could control
whether to stub-ize the native components with
a component attribute called Attributes.STUB_NATIVE.
getStubonly in interface Componentpublic void setStubonly(java.lang.String stubonly)
ComponentDefault: "inherit" (i.e., the same as the parent's stub-only, and "false" is assumed if none of parents is specified with stub-only).
If a component is set to stub-only, the application running at the server shall not access it anymore after rendered to the client. The ZK loader will try to minimize the memory footprint by merging stub-only components and replacing with light-weight components.
However, the event listeners and handlers are preserved, so
they will be invoked if the corresponding event is received.
Since the original component is gone, the event is the more generic
format: an instance of Event
(rather than MouseEvent or others).
If a component is stub-only, the application usually access it only at the client since all widgets are preserved at the client (so are events).
This method is available only for ZK EE.
setStubonly in interface Componentstubonly - whether it is stub-only. The allowed values include
"true", "false" and "inherit".public void setStubonly(boolean stubonly)
ComponentsetStubonly(stubonly ? "true": "false").setStubonly in interface Componentpublic boolean isInvalidated()
ComponentApplication developers rarely need to call this method.
Note:
Component.invalidate()
was not called against this component.isInvalidated in interface Componentpublic void invalidate()
ComponentIf the application is totally controlled by the server side (i.e., you don't write client codes), you rarely need to access this method.
It can be called only in the request-processing and event-processing phases. However, it is NOT allowed in the rendering phase.
invalidate in interface Componentpublic void invalidatePartial()
ComponentCtrlIf the application is totally controlled by the server side (i.e., you don't write client codes), you rarely need to access this method.
It can be called only in the request-processing and event-processing phases. However, it is NOT allowed in the rendering phase.
invalidatePartial in interface ComponentCtrlprotected void response(AuResponse response)
response(response.getOverrideKey(), response)
If AuResponse.getDepends() is not null, the response
depends on the existence of the component returned by
AuResponse.getDepends().
In other words, the response is removed if the component is removed.
If it is null, the response is component-independent and it is
always sent to the client.
Unlike smartUpdate(java.lang.String, java.lang.Object), responses are sent even if
Component.invalidate() was called.
Typical examples include setting the focus, selecting the text and so on.
It can be called only in the request-processing and event-processing phases; excluding the redrawing phase.
response(String, AuResponse)protected void response(java.lang.String key,
AuResponse response)
AuResponse.getOverrideKey()).
If AuResponse.getDepends() is not null, the response
depends on the existence of the component returned by
AuResponse.getDepends().
In other words, the response is removed if the component is removed.
If it is null, the response is component-independent and it is
always sent to the client.
Unlike smartUpdate(java.lang.String, java.lang.Object), responses are sent even if
Component.invalidate() was called.
Typical examples include setting the focus, selecting the text and so on.
It can be called only in the request-processing and event-processing phases; excluding the redrawing phase.
key - could be anything.
The second invocation of this method
in the same execution with the same key and the same depends
(AuResponse.getDepends()) will override the previous one.
However, if key is null, it won't override any other. All responses
with key == null will be sent.AuResponse.getDepends() is null, then be careful
of the key you used since it is shared in the same execution
(rather than a particular component).protected void response(java.lang.String key,
AuResponse response,
int priority)
AuResponse.getOverrideKey()).
If AuResponse.getDepends() is not null, the response
depends on the existence of the component returned by
AuResponse.getDepends().
In other words, the response is removed if the component is removed.
If it is null, the response is component-independent and it is
always sent to the client.
Unlike smartUpdate(java.lang.String, java.lang.Object), responses are sent even if
Component.invalidate() was called.
Typical examples include setting the focus, selecting the text and so on.
It can be called only in the request-processing and event-processing phases; excluding the redrawing phase.
key - could be anything.
The second invocation of this method
in the same execution with the same key and the same depends
(AuResponse.getDepends()) will override the previous one.
However, if key is null, it won't override any other. All responses
with key == null will be sent.AuResponse.getDepends() is null, then be careful
of the key you used since it is shared in the same execution
(rather than a particular component).priority - The higher priority, the earlier the update is executed.
The priority of response(AuResponse)
and response(String, AuResponse) is assumed to be 0.
If the priority is the same, the update is executed in the order of first-in-first out.
protected void smartUpdate(java.lang.String attr,
java.lang.Object value)
The second invocation with the same property will replace the previous
call. In other words, the same property will be set only once in
each execution. If you prefer to send both updates to the client,
use smartUpdate(String, Object, boolean) instead.
This method has no effect if invalidate() is ever invoked
(in the same execution), since invalidate() assumes
the whole content shall be redrawn and all smart updates to
this components can be ignored,
Once invalidate() is called, all invocations to smartUpdate(String, Object)
will then be ignored, and redraw(java.io.Writer) will be invoked later.
It can be called only in the request-processing and event-processing phases; excluding the redrawing phase.
There are two ways to draw a component, one is to invoke
Component.invalidate(), and the other is smartUpdate(String, Object).
While Component.invalidate() causes the whole content to redraw,
smartUpdate(String, Object) let component developer control which part
to redraw.
value - the new value.
If it is DeferredValue, the value
will be retrieved (by calling DeferredValue.getValue())
in the rendering phase. It is useful if the value can not be determined now.
For some old application servers (example, Websphere 5.1),
Execution.encodeURL(java.lang.String) cannot be called in the event processing
thread. So, the developers have to use DeferredValue
or disable the use of the event processing thread
(by use of disable-event-thread in zk.xml).
If you want to generate the JavaScript code directly (i.e.,
the value is a valid JavaScript snippet), you can use
JavaScriptValue. Notice that the JavaScript code will be evaluated
before assigning it to the widget.
If the value is a Date object, a special pattern will be generated
(a.k.a., marshaling)
to ensure it can be unmarshalled back correctly at the client.
Notice that it is marshalled to a string based
on TimeZones.getCurrent(), and then
unmarshalled back at the client. In other words, if the client
is in different time-zone, the value returned by getTime() might
be different. However, the value will remain the same if
the client marshalled the Date object back.
In other words, it assumes the browser's time zone from enduser's
perspective (not really browser's setting) shall be the same
as TimeZones.getCurrent().
If the value is a component, a special pattern will be generated to ensure it can be unmarshalled back correctly at the client.
In addition, the value can be any kind of objects that
the client accepts (marshaled by JSON) (see also JSONAware).
updateByClient(java.lang.String, java.lang.Object),
smartUpdate(String, Object, boolean)protected void smartUpdate(java.lang.String attr,
java.lang.Object value,
boolean append)
smartUpdate(String, Object) is a shortcut of
smartUpdate(attr, value, false).
For example, if you invoke smartUpdate("attr", "value1")
and smartUpdate("attr", "value2"), then only value2
will be sent to the client.
However, if you invoke smartUpdate("attr", "value1", true)
and smartUpdate("attr", "value2", true),
then both value1 and value2
will be sent to the client. In other words, wgt.setAttr("value1")
and wgt.setAttr("value2") will be invoked at the client
accordingly.
append - whether to append the updates of properties with the same
name. If false, only the last value of the same property will be sent
to the client.smartUpdate(String, Object)protected void smartUpdate(java.lang.String attr,
int value)
It is the same as smartUpdate(String, Object).
protected void smartUpdate(java.lang.String attr,
long value)
It is the same as smartUpdate(String, Object).
protected void smartUpdate(java.lang.String attr,
byte value)
It is the same as smartUpdate(String, Object).
protected void smartUpdate(java.lang.String attr,
char value)
It is the same as smartUpdate(String, Object).
protected void smartUpdate(java.lang.String attr,
boolean value)
It is the same as smartUpdate(String, Object).
protected void smartUpdate(java.lang.String attr,
float value)
It is the same as smartUpdate(String, Object).
protected void smartUpdate(java.lang.String attr,
double value)
It is the same as smartUpdate(String, Object).
protected void smartUpdateWidgetListener(java.lang.String evtnm,
java.lang.String script)
setListener and it will be invoked as follows.
wgt.setListener([evtnm, script]);
Devices that supports it in another way have to override this
method. Devices that don't support it have to override this method
to throw UnsupportedOperationException.
evtnm - the event name, such as onClickscript - the script. If null, it means to remove the event
listener from the peer widgetprotected void smartUpdateWidgetOverride(java.lang.String name,
java.lang.String script)
setOverride as follows.
wgt.setOverride([name: script]);
Devices that supports it in another way have to override this method. Devices that don't support it have to override this method to throw UnsupportedOperationException.
name - the method name, such as setValuescript - the content of the method or field to override.
Notice that it must be a valid JavaScript snippet.
If null, the previous method/field override
will be removed. And, the method/field defined in original widget will
be restored.public void detach()
ComponentComponent.setParent(org.zkoss.zk.ui.Component) or Component.setPage(org.zkoss.zk.ui.Page) to
attach it to any page, it will be removed automatically
(from the client) after the current event is processed.public void beforeChildAdded(Component child, Component insertBefore)
beforeChildAdded in interface ComponentCtrlchild - the child to be added (never null).insertBefore - another child component that the new child
will be inserted before it. If null, the new child will be the
last child.ComponentCtrl.beforeChildAdded(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)public void beforeChildRemoved(Component child)
beforeChildRemoved in interface ComponentCtrlchild - the child to be removed (never null)ComponentCtrl.beforeChildRemoved(org.zkoss.zk.ui.Component)public void beforeParentChanged(Component parent)
beforeParentChanged in interface ComponentCtrlparent - the new parent. If null, it means detachment.ComponentCtrl.beforeParentChanged(org.zkoss.zk.ui.Component)public void onChildAdded(Component child)
onChildAdded in interface ComponentCtrlComponentCtrl.onChildAdded(org.zkoss.zk.ui.Component)public void onChildRemoved(Component child)
onChildRemoved in interface ComponentCtrlComponentCtrl.onChildRemoved(org.zkoss.zk.ui.Component)public void onPageAttached(Page newpage, Page oldpage)
onPageAttached in interface ComponentCtrlnewpage - the new page (never null).oldpage - the previous page, if any, or null if it didn't
belong to any page.ComponentCtrl.onPageAttached(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Page)public void onPageDetached(Page page)
onPageDetached in interface ComponentCtrlpage - the previous page (never null)ComponentCtrl.onPageDetached(org.zkoss.zk.ui.Page)public java.lang.String getWidgetClass()
Default: return the widget class based on the current mold
(by use of ComponentDefinition.getWidgetClass(org.zkoss.zk.ui.Component, java.lang.String)), or null
if not found.
To override in Java, you could invoke setWidgetClass(java.lang.String).
To override in ZUML, you could use the client namespace as follows.
<window xmlns:w="http://www.zkoss.org/2005/zk/client"
w:use="foo.MyWindow">
</window>
getWidgetClass in interface ComponentComponent.setWidgetClass(java.lang.String)public void setWidgetClass(java.lang.String wgtcls)
ComponentsetWidgetClass in interface Componentwgtcls - the widget's class name at the client side.
If null (or empty), the default one is used (see Component.getWidgetClass()).public java.lang.String getMold()
ComponentDefault: "default"
Since 5.0, the default can be overridden by specify a library property. For example, if the component's class name is org.zkoss.zul.Button, then you can override the default mold by specifying the property called "org.zkoss.zul.Button.mold" with the mold you want in zk.xml. For example,
<library-property>
<name>org.zkoss.zul.Button.mold</name>
<value>trendy</value>
</library-property>
Notice that it doesn't affect the deriving classes. If you want to change the deriving class's default mold, you have to specify them explicitly, too.
getMold in interface ComponentComponentDefinitionpublic void setMold(java.lang.String mold)
ComponentsetMold in interface Componentmold - the mold. If null or empty, "default" is assumed.ComponentDefinitionprotected java.lang.String getSpecialRendererOutput(Component comp) throws java.io.IOException
java.io.IOExceptionpublic boolean disableClientUpdate(boolean disable)
ComponentCtrlBy default, if a component is attached to a page, modifications that change the visual representation will be sent to the client to ensure the consistency.
Though rarely needed, you can disable the synchronization of the visual representation, if you prefer to update the client in a batch or the modification is caused by the client.
Notice:
Also notice that, with Component.invalidate(),
it is easy to synchronize the content of a component
(and its descendants) to the client.
disableClientUpdate in interface ComponentCtrlpublic boolean addRedrawCallback(Callback<ContentRenderer> callback)
ComponentCtrladdRedrawCallback in interface ComponentCtrlpublic boolean removeRedrawCallback(Callback<ContentRenderer> callback)
ComponentCtrlremoveRedrawCallback in interface ComponentCtrlpublic java.util.Collection<Callback<ContentRenderer>> getRedrawCallback()
ComponentCtrlgetRedrawCallback in interface ComponentCtrlpublic boolean addCallback(java.lang.String name,
Callback callback)
ComponentCtrladdCallback in interface ComponentCtrlpublic boolean removeCallback(java.lang.String name,
Callback callback)
ComponentCtrlremoveCallback in interface ComponentCtrlpublic java.util.Collection<Callback> getCallback(java.lang.String name)
ComponentCtrlgetCallback in interface ComponentCtrlpublic void redraw(java.io.Writer out)
throws java.io.IOException
Default: It uses JsContentRenderer to render all information
in JavaScript codes. For devices that don't support JavaScript,
it must override this method.
To generate all information, it first invokes
renderProperties(org.zkoss.zk.ui.sys.ContentRenderer) to render component's
properties,
and then redrawChildren(java.io.Writer) to redraw children (and descendants)
(by calling their redraw(java.io.Writer)).
If a derived class wants to render more properties, it can override
renderProperties(org.zkoss.zk.ui.sys.ContentRenderer).
If a derived class renders only a subset of its children
(such as paging/cropping), it could override redrawChildren(java.io.Writer).
If a deriving class wants to do something before
renderProperties(org.zkoss.zk.ui.sys.ContentRenderer), it has to override redraw(java.io.Writer).
If a deriving class doesn't want to render in JavaScript codes,
it has to override redraw(java.io.Writer) with the proper implementation
of ContentRenderer.
redraw in interface ComponentCtrljava.io.IOExceptionprotected void redrawChildren(java.io.Writer out)
throws java.io.IOException
Default: it invokes redraw(java.io.Writer) for all its children.
If a derived class renders only a subset of its children
(such as paging/cropping), it could override redrawChildren(java.io.Writer).
java.io.IOExceptionredraw(java.io.Writer)protected void renderProperties(ContentRenderer renderer) throws java.io.IOException
ComponentCtrl.redraw(java.io.Writer)) to render the
properties, excluding the enclosing tag and children.
Default: it renders getId() if it was assigned,
and event names if listened (and listed in getClientEvents()).
Note: it doesn't render getWidgetClass(), getUuid()
and getMold(), which are caller's job.
java.io.IOExceptionprotected void render(ContentRenderer renderer, java.lang.String name, java.lang.String value) throws java.io.IOException
renderProperties(org.zkoss.zk.ui.sys.ContentRenderer) to
render a string-value property.
It ignores if value is null or empty.
If you want to render it even if null/empty, invoke
ContentRenderer.render(String, String) directly.java.io.IOExceptionprotected void render(ContentRenderer renderer, java.lang.String name, java.lang.Object value) throws java.io.IOException
renderProperties(org.zkoss.zk.ui.sys.ContentRenderer) to
render a string-value property.
It ignores if value is null.
If you want to render it even if null, invoke
ContentRenderer.render(String, Object) directly.java.io.IOExceptionprotected void render(ContentRenderer renderer, java.lang.String name, boolean value) throws java.io.IOException
renderProperties(org.zkoss.zk.ui.sys.ContentRenderer) to
render a boolean-value property if it is true.
If you want to render it no matter true or false, use
ContentRenderer.render(String, boolean) directly.java.io.IOExceptionpublic java.util.Map<java.lang.String,java.lang.Integer> getClientEvents()
ComponentCtrl.CE_IMPORTANT, ComponentCtrl.CE_NON_DEFERRABLE, ComponentCtrl.CE_BUSY_IGNORE,
ComponentCtrl.CE_DUPLICATE_IGNORE and ComponentCtrl.CE_REPEAT_IGNORE).
Default: return the collection of events
added by getClientEvents().
Rather than overriding this method, it is suggested
to invoke addClientEvent(java.lang.Class<? extends org.zkoss.zk.ui.Component>, java.lang.String, int) in the static statement.
For example,
public MyComponent extend HtmlBasedComponent {
static {
addClientEvent(MyComponent.class, "onOpen", 0);
}getClientEvents in interface ComponentCtrlprotected static void addClientEvent(java.lang.Class<? extends Component> cls, java.lang.String evtnm, int flags)
addClientEvent(java.lang.Class<? extends org.zkoss.zk.ui.Component>, java.lang.String, int) is usually called in the static clause
when the class is loaded. For example,
public class MyWidget extends HtmlBasedComponent {
static {
addClientEvent(MyWidget.class, "onFly", 0);
}
...
For a programming language not easy to have the static
clause (such as Scala), addClientEvent(java.lang.Class<? extends org.zkoss.zk.ui.Component>, java.lang.String, int) can be called in
the constructors. Notice that it is better not to add the client event
later than the constructor, since the derived classes will copy
the client events defined in the base class, when the first time
addClientEvent(java.lang.Class<? extends org.zkoss.zk.ui.Component>, java.lang.String, int) is called with the class.
Since 5.0.4, it can be called in constructors (in additions to the static clause). On other hand, it can only be called in the static clause (executed when the class is loaded) in the prior version.
cls - the component's class (implementation class).flags - a combination of ComponentCtrl.CE_IMPORTANT, ComponentCtrl.CE_NON_DEFERRABLE
ComponentCtrl.CE_BUSY_IGNORE, ComponentCtrl.CE_DUPLICATE_IGNORE
and ComponentCtrl.CE_REPEAT_IGNORE.public boolean addEventListener(java.lang.String evtnm,
EventListener<? extends Event> listener)
ComponentYou could register listener to all components in the same page
by use of Page.addEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>).
ZK 5.0 and earlier, the second registration is ignored if an event listener has been registered twice. However, since 6.0.0 and later, it won't be ignored. If a listener has been registered multiple times, it will be invoked multiple times.
If you prefer to ignore the second registration, you could specify a library property called "org.zkoss.zk.ui.EventListener.duplicateIgnored" to true.
addEventListener in interface Componentevtnm - what event to listen (never null)Page.addEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>)public boolean addEventListener(int priority,
java.lang.String evtnm,
EventListener<? extends Event> listener)
ComponentYou could register listener to all components in the same page
by use of Page.addEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>).
ZK 5.0 and earlier, the second registration is ignored if an event listener has been registered twice. However, since 6.0.0 and later, it won't be ignored. If a listener has been registered multiple times, it will be invoked multiple times.
If you prefer to ignore the second registration, you could specify a library property called "org.zkoss.zk.ui.EventListener.duplicateIgnored" to true.
addEventListener in interface Componentpriority - the priority of the event. The higher the priority is, the earlier it
is invoked.Component.addEventListener(String, EventListener) is 0.evtnm - what event to listen (never null)Page.addEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>)public boolean removeEventListener(java.lang.String evtnm,
EventListener<? extends Event> listener)
ComponentremoveEventListener in interface Componentpublic boolean addForward(java.lang.String orgEvent,
Component target,
java.lang.String targetEvent)
ComponentDefault: no forward condition at all.
Once the condition is added, a event called targetEvent
is posted to the target component,
when this component receives the orginalEvent event.
addForward in interface ComponentorgEvent - the original event that was received
by this component. If null, "onClick" is assumed.target - the target component to receive the event.
If null, the space owner Component.getSpaceOwner() is assumed.
If null and the space owner is the page, the root component is assumed.targetEvent - the target event that the target component
will receive.
If null, it is the same as the original event.Component.removeForward(String, Component, String),
Component.addForward(String, Component, String, Object)public boolean addForward(java.lang.String orgEvent,
java.lang.String targetPath,
java.lang.String targetEvent)
ComponentNote: the target component is retrieved from the path, each time the event is received. Thus, you can reference to a component that is created later.
addForward in interface ComponentorgEvent - the original event that was received
by this component. If null, "onClick" is assumed.targetPath - the target component's path related to this component.
If ".", this component is assumed.
If null, the space owner is assumed.
If null and the space owner is the page, the root component is assumed.targetEvent - the target event that the target component
will receive.
If null, it is the same as the original event.Component.addForward(String, Component, String),
Component.removeForward(String, String, String)public boolean addForward(java.lang.String orgEvent,
Component target,
java.lang.String targetEvent,
java.lang.Object eventData)
ComponentaddForward in interface ComponenteventData - the extra data that can be retrieve by
Event.getData().Component.addForward(String, Component, String)public boolean addForward(java.lang.String orgEvent,
java.lang.String targetPath,
java.lang.String targetEvent,
java.lang.Object eventData)
ComponentaddForward in interface ComponenteventData - the extra data that can be retrieve by
Event.getData().Component.addForward(String, String, String)public boolean removeForward(java.lang.String orgEvent,
Component target,
java.lang.String targetEvent)
ComponentComponent.addForward(String, Component, String).
If no such forward condition exists, nothing happens but return false.removeForward in interface ComponentorgEvent - the original event that was received
by this component.
It must be the same as the one passed to Component.addForward(String, Component, String).target - the target component to receive the event.
It must be the same as the one passed to Component.addForward(String, Component, String).targetEvent - the target event that the target component will receive.
It must be the same as the one passed to Component.addForward(String, Component, String).Component.addForward(String, Component, String)public boolean removeForward(java.lang.String orgEvent,
java.lang.String targetPath,
java.lang.String targetEvent)
ComponentComponent.addForward(String, String, String).
If no such forward condition exists, nothing happens but return false.removeForward in interface ComponentorgEvent - the original event that was received
by this component.
It must be the same as the one passed to Component.addForward(String, Component, String).targetPath - the target component's path related to this component.
If ".", this component is assumed.
If null, the space owner is assumed.
If null and the space owner is the page, the root component is assumed.targetEvent - the target event that the target component will receive.
It must be the same as the one passed to Component.addForward(String, Component, String).Component.addForward(String, String, String)public boolean isListenerAvailable(java.lang.String evtnm,
boolean asap)
ComponentUnlike Events.isListened(org.zkoss.zk.ui.Component, java.lang.String, boolean),
this method checks only the event listener registered by
Component.addEventListener(int, java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>).
isListenerAvailable in interface Componentasap - whether to check only non-deferrable listener,
i.e., not implementing Deferrable,
or Deferrable.isDeferrable() is false.Deferrable,
Events.isListened(org.zkoss.zk.ui.Component, java.lang.String, boolean),
Component.addEventListener(int, java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>)public java.util.Iterator<EventListener<? extends Event>> getListenerIterator(java.lang.String evtnm)
getEventListeners(java.lang.String).getListenerIterator in interface Componentpublic java.lang.Iterable<EventListener<? extends Event>> getEventListeners(java.lang.String evtnm)
ComponentNote: it is OK to invoke Component.addEventListener(int, java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>) or Component.removeEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>)
when iterating through the event listeners with the returned collection.
To remove an event listener from the returned iterable collection,
you could invoke Iterable.iterator()'s Iterator.remove().
getEventListeners in interface Componentpublic void applyProperties()
ComponentThis method is invoked automatically if a component is created by evaluating a ZUML page, i.e., if it is specified as an element of a ZUML page.
On the other hand, if it is created manually (by program),
developer might choose to invoke this method or not,
depending whether he wants to
initializes the component with the properties
defined in the ZUML page (PageDefinition)
and the language definition (LanguageDefinition).
Notice that, since 5.0.7, custom-attributes are applied automatically
in the constructor of AbstractComponent, so they are always
available no matter this method is called or not.
applyProperties in interface Componentpublic ComponentDefinition getDefinition()
ComponentgetDefinition in interface Componentpublic void setDefinition(ComponentDefinition compdef)
ComponentCtrlThe component definition affects how a component behaves. Developers rarely need to call this method. If a wrong definition is assigned, the result is unpredictable (and hard to debug). It is mainly designed for developing tools.
setDefinition in interface ComponentCtrlpublic void setDefinition(java.lang.String name)
ComponentCtrlsetDefinition in interface ComponentCtrlname - the name of the component definitionpublic ZScript getEventHandler(java.lang.String evtnm)
ComponentCtrlgetEventHandler in interface ComponentCtrlComponent.getWidgetListener(java.lang.String)public void addSharedEventHandlerMap(EventHandlerMap evthds)
ComponentCtrladdSharedEventHandlerMap in interface ComponentCtrlevthds - a map of event handlerComponent.setWidgetListener(java.lang.String, java.lang.String)public java.util.Set<java.lang.String> getEventHandlerNames()
ComponentCtrlgetEventHandlerNames in interface ComponentCtrlComponent.getWidgetListenerNames()public void addEventHandler(java.lang.String name,
EventHandler evthd)
ComponentCtrlComponent.setWidgetListener(java.lang.String, java.lang.String) will
overwrite the previous listener if the event name is the same.addEventHandler in interface ComponentCtrlComponent.setWidgetListener(java.lang.String, java.lang.String)public Annotation getAnnotation(java.lang.String annotName)
getAnnotation(String, String).getAnnotation in interface ComponentCtrlpublic Annotation getAnnotation(java.lang.String propName, java.lang.String annotName)
ComponentCtrlIf there are multiple annotation with the given name,
this method will merge them before return. If you prefer to get all
of them without merging, please use ComponentCtrl.getAnnotations(String, String) instead.
For example,
<textbox value="@bind(abc, param1=foo1) @bind(xyz, param2=foo2)">
This method will return a single annotation with three attributes:
value=xyz, param1=foo1 and param2=foo2. On the other hand,
ComponentCtrl.getAnnotations(String, String) will return a two-element
collections.
Notice that the property is button doesn't have setFoo method.
And, you can retrieve it by use of this method (getAnnotation("foo", "bind"))
<button foo="@bind(whatever=123)"/>
Furthermore, you can declare it as custom-attribute.
For example, the following is equivalent to the above.
<button>
<custom-attribute foo="@bind(whatever=123}">
</button>getAnnotation in interface ComponentCtrlpropName - the property name, e.g., "value".
If null, this method returns the annotation(s) associated with this
component (rather than a particular property).annotName - the annotation nameComponentCtrl.getAnnotations(String, String)public java.util.Collection<Annotation> getAnnotations(java.lang.String propName, java.lang.String annotName)
ComponentCtrlNotice that the property is button doesn't have setFoo method.
And, you can retrieve it by use of this method (getAnnotation("foo", "bind"))
<button foo="@bind(whatever=123)"/>
Furthermore, you can declare it as custom-attribute.
For example, the following is equivalent to the above.
<button>
<custom-attribute foo="@bind(whatever=123}">
</button>getAnnotations in interface ComponentCtrlpropName - the property name, e.g., "value".
If null, this method returns the annotation(s) associated with this
component (rather than a particular property).annotName - the annotation nameComponentCtrl.getAnnotation(String, String)public java.util.Collection<Annotation> getAnnotations()
getAnnotations(String).getAnnotations in interface ComponentCtrlpublic java.util.Collection<Annotation> getAnnotations(java.lang.String propName)
ComponentCtrlAnnotation)
associated with the specified property. It never returns null.getAnnotations in interface ComponentCtrlpropName - the property name, e.g., "value".
If null, this method returns the annotation(s) associated with this
component (rather than a particular property).public java.util.List<java.lang.String> getAnnotatedPropertiesBy(java.lang.String annotName)
ComponentCtrlgetAnnotatedPropertiesBy in interface ComponentCtrlpublic java.util.List<java.lang.String> getAnnotatedProperties()
ComponentCtrlgetAnnotatedProperties in interface ComponentCtrlpublic void addAnnotation(java.lang.String annotName,
java.util.Map<java.lang.String,java.lang.String[]> annotAttrs)
addAnnotation(String, String, Map)addAnnotation in interface ComponentCtrlpublic void addAnnotation(java.lang.String propName,
java.lang.String annotName,
java.util.Map<java.lang.String,java.lang.String[]> annotAttrs)
ComponentCtrlIf the given property is null, the annotation is associated to this component, rather than a particular property.
Unlike Java, you can add annotations dynamically, and each component has its own annotations.
addAnnotation in interface ComponentCtrlpropName - the property name.
If null, the annotation is associated with the component (rather than
a particular property).annotName - the annotation name (never null, nor empty).annotAttrs - a map of attributes, or null if no attribute at all.
This method will make a copy of annotAttrs, so the caller
can use it after the invocation.public void sessionWillPassivate(Page page)
ComponentCtrlNote: only root components are notified by this method.
sessionWillPassivate in interface ComponentCtrlpublic void sessionDidActivate(Page page)
ComponentCtrlNote: only root components are notified by this method.
sessionDidActivate in interface ComponentCtrlprotected void willPassivate(java.util.Collection<?> c)
ComponentActivationListener.willPassivate(org.zkoss.zk.ui.Component)
for each object in the collection.c - a collection of objects. Ignored if null.protected void willPassivate(java.lang.Object o)
ComponentActivationListener.willPassivate(org.zkoss.zk.ui.Component)
for the specified object.o - the object to invoke. Ignore if
ComponentActivationListener not implemented or null.protected void didActivate(java.util.Collection<?> c)
ComponentActivationListener.didActivate(org.zkoss.zk.ui.Component)
for each object in the collection.c - a collection of objects. Ignored if null.protected void didActivate(java.lang.Object o)
ComponentActivationListener.didActivate(org.zkoss.zk.ui.Component)
for the specified object.o - the object to invoke. Ignore if
ComponentActivationListener not implemented or null.public java.lang.Object getExtraCtrl()
Default: null.
getExtraCtrl in interface ComponentCtrlCropper.ComponentCtrl.getExtraCtrl()public PropertyAccess getPropertyAccess(java.lang.String prop)
ComponentCtrlgetPropertyAccess in interface ComponentCtrlprop - the name of the propertypublic WrongValueException onWrongValue(WrongValueException ex)
WrongValueException instance is thrown,
and WrongValueException.getComponent() is this component.
It is a callback and the component can store the error message,
show up the custom information, or even 'eat' the exception.
Default: does nothing but returns ex.
onWrongValue in interface ComponentCtrlex - the exception being thrown (never null)public AuService getAuService()
ComponentDefault: null
getAuService in interface Componentpublic void setAuService(AuService ausvc)
ComponentDefault: null.
If you want to provide an AU service for the AU requests
targeting the desktop. Use Desktop.addListener(java.lang.Object).
See also How to process AU requests with JSON.
setAuService in interface Componentpublic void service(AuRequest request, boolean everError)
Default: it handles echo and setAttr, and it converts other request
to an event (by Event.getEvent(org.zkoss.zk.au.AuRequest)) and then posts the event
(by Events.postEvent(org.zkoss.zk.ui.event.Event)).
Application developer can plug the custom service to handle
the AU request by setAuService(org.zkoss.zk.au.AuService).
service in interface ComponentCtrleverError - whether any error ever occurred before
processing this request.setAuService(org.zkoss.zk.au.AuService)public void service(Event event, Scope scope) throws java.lang.Exception
ComponentCtrlservice in interface ComponentCtrlevent - the event to handlescope - the scope to evaluate the zscript, if any.
(see also Page.interpret(java.lang.String, java.lang.String, org.zkoss.zk.ui.ext.Scope).java.lang.Exceptionpublic EventListenerMap getEventListenerMap()
ComponentCtrlgetEventListenerMap in interface ComponentCtrlprotected void updateByClient(java.lang.String name,
java.lang.Object value)
setAttr
(by invoking zk.Widget's smartUpdate at client).
By default, it does nothing but log a warning message, since it is not safe to allow the client to update a field arbitrary.
However, if you'd like to allow the update for a particular component you could do one of the following
protected void updateByClient(String name, Object value) {
if ("disabled".equals(name))
setDisabled(name, ((Boolean)value).booleanValue());
else
super.updateByClient(name, value);org.zkoss.zk.ui.updateByClient to be true.
Then, this method will use reflection to find out the setter to update
the value. Nothing happens if the method is not found.Notice: this method will invoke disableClientUpdate(boolean) to
disable any update to the client, when calling the setter.
If you want to enable the client update for all instances of a given component (though not recommended for the security reason), you could refer to here.
See also zk.Widget.smartUpdate().
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.Object clone()
Componentprotected void willSerialize(java.util.Collection c)
ComponentSerializationListener.willSerialize(org.zkoss.zk.ui.Component)
for each object in the collection.c - a collection of objects. Ignored if null.protected void willSerialize(java.lang.Object o)
ComponentSerializationListener.willSerialize(org.zkoss.zk.ui.Component)
for the specified object.o - the object to invoke. Ignore if
ComponentSerializationListener not implemented or null.protected void didDeserialize(java.util.Collection c)
ComponentSerializationListener.didDeserialize(org.zkoss.zk.ui.Component)
for each object in the collection.c - a collection of objects. Ignored if null.protected void didDeserialize(java.lang.Object o)
ComponentSerializationListener.didDeserialize(org.zkoss.zk.ui.Component)
for the specified object.o - the object to invoke. Ignore if
ComponentSerializationListener not implemented or null.protected java.lang.String getDefaultMold(java.lang.Class<? extends Component> klass)
Default: check the library property called xxx.mold, where xxx is the name of the give class. If not found or empty, "default" is assumed.
Subclass might override this method to use the default mold of the base class, such as
protected String getDefaultMold(Class klass) {
return super.getDefaultMold(Button.class);
}public Template getTemplate(java.lang.String name)
ComponentgetTemplate in interface ComponentComponent.setTemplate(java.lang.String, org.zkoss.zk.ui.util.Template)public Template setTemplate(java.lang.String name, Template template)
ComponentComponent.getTemplate(java.lang.String).setTemplate in interface Componentname - the template's name. It cannot be empty or null.template - the template to assign. If it is null, the previous
template, if any, will be removedpublic java.util.Set<java.lang.String> getTemplateNames()
ComponentgetTemplateNames in interface Componentpublic Component query(java.lang.String selector)
Componentquery in interface Componentselector - the CSS3 selector. For example, comp.query("#id div").Component.queryAll(java.lang.String)public java.lang.Iterable<Component> queryAll(java.lang.String selector)
ComponentNotice: this method traverses the whole component tree, only if you iterate through the whole iterable object. In other words, the performance is good, and you can iterate it find the object that matches your criteria.
queryAll in interface Componentselector - the CSS3 selector. For example, comp.queryAll("#id div").Component.query(java.lang.String)public <T extends ShadowElement> java.util.List<T> getShadowRoots()
ComponentCtrlgetShadowRoots in interface ComponentCtrlpublic boolean removeShadowRoot(ShadowElement shadow)
ComponentCtrlremoveShadowRoot in interface ComponentCtrlshadow - a shadow elementpublic boolean addShadowRoot(ShadowElement shadow)
ComponentCtrladdShadowRoot in interface ComponentCtrlshadow - a shadow elementpublic boolean addShadowRootBefore(ShadowElement shadow, ShadowElement insertBefore)
ComponentCtrladdShadowRootBefore in interface ComponentCtrlshadow - a shadow elementinsertBefore - the shadow before which you want the new childpublic boolean hasBindingAnnotation()
ComponentCtrlhasBindingAnnotation in interface ComponentCtrlpublic boolean hasSubBindingAnnotation()
ComponentCtrlhasSubBindingAnnotation in interface ComponentCtrlpublic int getSubBindingAnnotationCount()
ComponentCtrlgetSubBindingAnnotationCount in interface ComponentCtrlprotected void updateSubBindingAnnotationCount(int diff)
protected void setSubBindingAnnotationCount(int diff,
AbstractComponent node)
public void enableBindingAnnotation()
ComponentCtrlenableBindingAnnotation in interface ComponentCtrlpublic void disableBindingAnnotation()
ComponentCtrldisableBindingAnnotation in interface ComponentCtrlpublic ShadowElement getShadowFellowIfAny(java.lang.String id)
ComponentCtrlgetShadowFellowIfAny in interface ComponentCtrlpublic boolean isInitialized()
Copyright © 2005-2024 Potix Corporation. All Rights Reserved.