|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.zk.ui.AbstractComponent
public class AbstractComponent
A skeletal implementation of Component. Though it is OK
to implement Component from scratch, this class simplifies some of
the chores.
| Nested Class Summary | |
|---|---|
protected class |
AbstractComponent.Children
The default implementation for newChildren(). |
| Field Summary | |
|---|---|
protected boolean |
_visible
Whether this component is visible. |
| Fields inherited from interface org.zkoss.zk.ui.Component |
|---|
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE |
| Constructor Summary | |
|---|---|
AbstractComponent()
Constructs a component with auto-generated ID. |
|
| Method Summary | |
|---|---|
void |
addAnnotation(java.lang.String annotName,
java.util.Map annotAttrs)
Associates an annotation to this component. |
void |
addAnnotation(java.lang.String propName,
java.lang.String annotName,
java.util.Map annotAttrs)
Adds an annotation to the specified proeprty of this component. |
void |
addEventHandler(java.lang.String name,
EventHandler evthd)
Adds an event handler. |
boolean |
addEventListener(java.lang.String evtnm,
EventListener listener)
Adds an event listener to specified event 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. |
void |
addSharedAnnotationMap(AnnotationMap annots)
Add a map of annotations which is shared by other components. |
void |
addSharedEventHandlerMap(EventHandlerMap evthds)
Adds a map of event handlers which is shared by other components. |
protected java.lang.StringBuffer |
appendAsapAttr(java.lang.StringBuffer sb,
java.lang.String evtnm)
Detects if a non-deferrable event is registered, and appends a special attribute to denote it if true. |
protected java.lang.StringBuffer |
appendAsapAttr(java.lang.StringBuffer sb,
java.lang.String evtnm,
boolean enforce)
Appends an attribute for the specified event name, say, onChange, if a non-deferrable listener is registered or enforce is true. |
boolean |
appendChild(Component child)
Appends a child to the end of all children. |
void |
applyProperties()
Initializes the properties (aka. members) and custom-attributes 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: does nothing. |
java.lang.Object |
clone()
Clones the component. |
boolean |
containsVariable(java.lang.String name,
boolean local)
Returns whether the specified variable is defined. |
void |
detach()
Detaches this component such that it won't belong to any page. |
boolean |
disableClientUpdate(boolean disable)
Sets whether to disable the update of the client widgets of this component and its descendants. |
boolean |
equals(java.lang.Object o)
|
java.util.List |
getAnnotatedProperties()
Returns a read-only list of the name (String) of properties that are associated at least one annotation (never null). |
java.util.List |
getAnnotatedPropertiesBy(java.lang.String annotName)
Returns a read-only list of the names (String) of the properties that are associated with the specified annotation (never null). |
Annotation |
getAnnotation(java.lang.String annotName)
Returns the annotation associated with the component, or null if not available. |
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 |
getAnnotations()
Returns a read-only collection of all annotations associated with this component (never null). |
java.util.Collection |
getAnnotations(java.lang.String propName)
Returns a read-only collection of all annotations associated with the specified property (never null). |
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,
int scope)
Returns the value of the specified custom attribute in the specified scope, or null if not defined. |
java.util.Map |
getAttributes()
Returns all custom attributes associated with this component, i.e., Component.COMPONENT_SCOPE. |
java.util.Map |
getAttributes(int scope)
Returns all custom attributes of the specified scope. |
java.util.List |
getChildren()
Returns a live list of children. |
Command |
getCommand(java.lang.String cmdId)
Returns the command of the specified command ID, or null if not found. |
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 handler of the specified name, or null if not found. |
java.util.Set |
getEventHandlerNames()
Returns a readonly collection of event names (String), or an empty collection if no event name is registered. |
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 |
getFellowIfAny(java.lang.String compId)
Returns a component of the specified ID in the same ID space, or null if not found. |
java.util.Collection |
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 |
getListenerIterator(java.lang.String evtnm)
Returns an iterator for iterating listener for the specified event. |
java.lang.String |
getMold()
Returns the mold used to render this component. |
protected java.lang.Object |
getMoldURI()
Returns the mold URI based on getMold()
and the molds defined in the component definition
(ComponentDefinition). |
Namespace |
getNamespace()
Returns the namespace to store variables and functions belonging to the ID space of 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. |
Component |
getRoot()
Returns the root of the specified component. |
IdSpace |
getSpaceOwner()
Returns the owner of the ID space that this component belongs to. |
java.lang.String |
getUuid()
Returns UUID (universal unique ID) which is unquie in the whole session. |
java.lang.Object |
getVariable(java.lang.String name,
boolean local)
Returns the value of a variable defined in the namespace, or null if not defined or the value is null. |
boolean |
hasFellow(java.lang.String compId)
|
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 later. |
protected boolean |
isAsapRequired(java.lang.String evtnm)
Returns if any non-deferrable (ASAP) event listener is registered for the specified event. |
boolean |
isChildable()
Default: return true (allows to have children). |
boolean |
isInvalidated()
Returns if this component needs to be redrawn. |
boolean |
isListenerAvailable(java.lang.String evtnm,
boolean asap)
Returns whether the event listener is available. |
boolean |
isVisible()
Returns whether this component is visible. |
protected java.util.List |
newChildren()
Creates and returns the instance for storing child components. |
protected java.lang.Object |
newExtraCtrl()
Used by getExtraCtrl() to create extra controls. |
void |
onChildAdded(Component child)
Default: does nothing. |
void |
onChildRemoved(Component child)
Default: does nothing. |
void |
onDrawNewChild(Component child,
java.lang.StringBuffer out)
Called when a new-created child is about to render. |
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. |
void |
redraw(java.io.Writer out)
Redraws this component. |
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,
int scope)
Removes the specified custom attribute in the specified scope. |
boolean |
removeChild(Component child)
Removes a child. |
boolean |
removeEventListener(java.lang.String evtnm,
EventListener 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). |
void |
response(java.lang.String key,
AuResponse response)
Causes a response to be sent to the client. |
void |
sessionDidActivate(Page page)
Notification that the session, which owns this component, has just been activated (aka., deserialized). |
void |
sessionWillPassivate(Page page)
Notification that the session, which owns this component, is about to be passivated (aka., 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,
int scope)
Sets the value of the specified custom attribute in the specified scope. |
void |
setComponentDefinition(ComponentDefinition compdef)
Sets the component definition. |
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 |
setVariable(java.lang.String name,
java.lang.Object val,
boolean local)
Sets a variable to the namespace. |
boolean |
setVisible(boolean visible)
Sets whether this component is visible. |
void |
smartUpdate(java.lang.String attr,
boolean value)
A special smart-update that update a value in boolean. |
void |
smartUpdate(java.lang.String attr,
int value)
A special smart-update that update a value in int. |
void |
smartUpdate(java.lang.String attr,
java.lang.String value)
Smart-updates a property with the specified value. |
void |
smartUpdateDeferred(java.lang.String attr,
DeferredValue value)
Smart-updates a property with a deferred value. |
void |
smartUpdateValues(java.lang.String attr,
java.lang.Object[] values)
Smart-updates a property with an array of values. |
java.lang.String |
toString()
|
void |
unsetVariable(java.lang.String name,
boolean local)
Unsets a variable defined in the namespace. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected boolean _visible
| Constructor Detail |
|---|
public AbstractComponent()
| Method Detail |
|---|
protected java.util.List newChildren()
Default: it instantiates AbstractComponent.Children.
protected java.lang.Object getMoldURI()
getMold()
and the molds defined in the component definition
(ComponentDefinition).
As of release 3.0.0, it may return a String instance representing
the URI, or a ComponentRenderer instance responsible for
redrawing.
Used only for component implementation.
public final Page getPage()
ComponentWhen a component is created (aka., 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)
explicityly.
getPage in interface ComponentComponent.setParent(org.zkoss.zk.ui.Component),
Component.setPage(org.zkoss.zk.ui.Page)public final 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 (thru 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.
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 redudant 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()
ComponentIf 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.
A page itself is also an ID space, so you could retrieve
compnents 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. In other word, a variable named by the ID is created automatically.
getId in interface ComponentPagepublic void setId(java.lang.String id)
ComponentComponent.getId() for more details.
When a component is constructed, an ID is generated automatically. Thus, calling this method only you need to identify a component.
setId in interface Componentid - the identifier. It cannot be empty.
If null, it means the previous ID is removed (aka., reset)
and an anonymous ID is assigned.Pagepublic final 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.
getUuid in interface Componentpublic final 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 relevant methods include Component.getFellow(java.lang.String),
Component.getAttribute(java.lang.String, int) and Component.getVariable(java.lang.String, boolean).
getSpaceOwner in interface ComponentComponent.getNamespace()public boolean hasFellow(java.lang.String compId)
public Component getFellow(java.lang.String compId)
ComponentUnlike Component.getFellowIfAny(java.lang.String), it throws an exception if not found.
getFellow in interface Componentpublic Component getFellowIfAny(java.lang.String compId)
ComponentUnlike Component.getFellow(java.lang.String), it returns null if not found.
getFellowIfAny in interface Componentpublic java.util.Collection getFellows()
Component
getFellows in interface Componentpublic Component getNextSibling()
Component
getNextSibling in interface Componentpublic Component getPreviousSibling()
Component
getPreviousSibling in interface Componentpublic Component getFirstChild()
Component
getFirstChild in interface Componentpublic Component getLastChild()
Component
getLastChild in interface Componentpublic java.util.Map 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 desktopas this one's.
getAttributes 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 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 desktopas this one's.
getAttribute 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 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, while Component.setVariable(java.lang.String, java.lang.Object, boolean) considers null as a legal value.
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 desktopas this one's.
setAttribute in interface Componentvalue - the value. If null, the attribute is removed.scope - 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,
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 desktopas 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 final java.util.Map getAttributes()
ComponentComponent.COMPONENT_SCOPE.
getAttributes in interface ComponentgetAttributes in interface Scopepublic final java.lang.Object getAttribute(java.lang.String name)
ComponentComponent.COMPONENT_SCOPE.
getAttribute in interface ComponentgetAttribute in interface Scope
public final java.lang.Object setAttribute(java.lang.String name,
java.lang.Object value)
ComponentComponent.COMPONENT_SCOPE.
setAttribute in interface Componentpublic final java.lang.Object removeAttribute(java.lang.String name)
ComponentComponent.COMPONENT_SCOPE.
removeAttribute in interface Component
public void setVariable(java.lang.String name,
java.lang.Object val,
boolean local)
ComponentThis method is the same as getNamespace().setVariable(name, value, local).
Once a variable is set thru this method, it is visible to both the interpreter and EL.
Note: Exactly one namespace is allocated for each ID space.
For example, if the space owner of this component is the page, then
the returned namespace is the same as Page.getNamespace().
Otherwise, it is the same as the namspace returned by the component
owning this ID space.
First, only the ID space support Component.setVariable(java.lang.String, java.lang.Object, boolean) and so.
Second, the variables can be referenced directly in zscript and EL
expressions, while attributes are referenced thru the scope,
such as spaceScope.
On the other hand, using attributes causes less name popultion.
In general, if you could use attributes, don't use variable.
setVariable in interface Componentlocal - whether not to search any of the ancestor namespace defines
the variable. If local is false and an ancesotor has defined a variable
with the same name, the variable in the ancestor is changed directly.
Otherwise, a new variable is created in the namespace containing
this component.Component.getSpaceOwner(),
Component.getNamespace()
public boolean containsVariable(java.lang.String name,
boolean local)
ComponentNote: null is a valid value for variable, so this method is used
to know whether a variable is defined.
On the other hand, Component.setAttribute(java.lang.String, java.lang.Object, int) actually remove
an attribute (by Component.removeAttribute(java.lang.String, int) if value is null.
containsVariable in interface Componentlocal - whether not to search its ancestor.
If false and the current namespace doen't define the variable,
it searches up its ancestor (via Component.getParent()) to see
any of them has defined the specified variable.
public java.lang.Object getVariable(java.lang.String name,
boolean local)
ComponentThis method is the same as getNamespace().getVariable(name, local).
Component.getVariable(java.lang.String, boolean) and Page.getZScriptVariable(java.lang.String)Component.getVariable(java.lang.String, boolean) returns only variables defined by
Component.setVariable(java.lang.String, java.lang.Object, boolean) (i.e., a shortcut of Namespace.setVariable(java.lang.String, java.lang.Object, boolean)).
On the other hand, Page.getZScriptVariable(java.lang.String) returns these variables
and those defined when executing zscripts.
getVariable in interface Componentlocal - whether not to search its ancestor.
If false and the current namespace doen't define the variable,
it searches up its ancestor (via Component.getParent()) to see
any of them has defined the specified variable.Component.getSpaceOwner(),
Component.getNamespace()
public void unsetVariable(java.lang.String name,
boolean local)
ComponentThis method is the same as getNamespace().getVariable(name, local).
unsetVariable in interface Componentlocal - whether not to search its ancestor.
If false and the current namespace doen't define the variable,
it searches up its ancestor (via Component.getParent()) to see
any of them has defined the specified variable.Component.getSpaceOwner(),
Component.getNamespace()public Component getParent()
Component
getParent in interface 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.
setParent in interface Component
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.
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.
public final 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.
removeChild in interface Componentpublic boolean isChildable()
isChildable in interface Componentpublic java.util.List getChildren()
Component
getChildren in interface Componentpublic Component getRoot()
getRoot in interface Componentpublic boolean isVisible()
Component
isVisible in interface ComponentComponents.isRealVisible(org.zkoss.zk.ui.Component)public boolean setVisible(boolean visible)
Component
setVisible in interface Componentpublic boolean isInvalidated()
ComponentNote:
Component.invalidate()
was not called against this component.
isInvalidated in interface Componentpublic void invalidate()
ComponentIt can be called only in the request-processing and event-processing phases; excluding the redrawing phase.
invalidate in interface Component
public void response(java.lang.String key,
AuResponse response)
ComponentCtrlIf AuResponse.getDepends() is not null, the response
depends on the existence of the returned componet.
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 ComponentCtrl.smartUpdate(java.lang.String, java.lang.String), 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 in interface ComponentCtrlkey - could be anything.
The second invocation of this method
in the same execution with the same key will override the previous one.
However, if key is null, it won't override any other. All responses
with key == null will be sent.
public void smartUpdate(java.lang.String attr,
java.lang.String value)
ComponentCtrlThe 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.
This method has no effect if Component.invalidate() is ever invoked
(in the same execution), since Component.invalidate() assumes
the whole content shall be redrawn and all smart updates to
this components can be ignored,
Once this method is called, all invocations to ComponentCtrl.smartUpdate(java.lang.String, java.lang.String)
will then be ignored, and Component.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 ComponentCtrl.smartUpdate(java.lang.String, java.lang.String).
While Component.invalidate() causes the whole content to redraw,
ComponentCtrl.smartUpdate(java.lang.String, java.lang.String) let component developer control which part
to redraw.
smartUpdate in interface ComponentCtrlvalue - the new value. If null, it means removing the property.ComponentCtrl.smartUpdateDeferred(java.lang.String, org.zkoss.zk.ui.util.DeferredValue),
ComponentCtrl.smartUpdateValues(java.lang.String, java.lang.Object[])
public void smartUpdateDeferred(java.lang.String attr,
DeferredValue value)
smartUpdateDeferred in interface ComponentCtrlComponentCtrl.smartUpdate(java.lang.String, java.lang.String),
ComponentCtrl.smartUpdateValues(java.lang.String, java.lang.Object[])
public void smartUpdateValues(java.lang.String attr,
java.lang.Object[] values)
ComponentCtrl
smartUpdateValues in interface ComponentCtrlvalues - an array of values. Any of them must be an instance
of String or DeferredValue.ComponentCtrl.smartUpdate(java.lang.String, java.lang.String),
ComponentCtrl.smartUpdateDeferred(java.lang.String, org.zkoss.zk.ui.util.DeferredValue)
public void smartUpdate(java.lang.String attr,
int value)
It will invoke smartUpdate(String,String) to update
the attribute eventually.
public void smartUpdate(java.lang.String attr,
boolean value)
It will invoke smartUpdate(String,String) to update
the attribute eventually.
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.
detach in interface Component
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 getMold()
getMold in interface ComponentComponentDefinitionpublic void setMold(java.lang.String mold)
Component
setMold in interface Componentmold - the mold. If null or empty, "default" is assumed.ComponentDefinitionpublic boolean disableClientUpdate(boolean disable)
ComponentCtrlBy default, if a component is attached to a page, modications 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 batchly 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 ComponentCtrl
public void redraw(java.io.Writer out)
throws java.io.IOException
getMoldURI() to retrieve the mold
to redraw. The mold is either an URI (String) or a
ComponentRenderer instance.
Execution.include(java.io.Writer, java.lang.String, java.util.Map, int) to generate
the output.ComponentRenderer instance, ComponentRenderer.render(org.zkoss.zk.ui.Component, java.io.Writer)
is called to generate the output.
redraw in interface Componentjava.io.IOException
public void onDrawNewChild(Component child,
java.lang.StringBuffer out)
throws java.io.IOException
ComponentCtrlIt is called in the redrawing phase by the kernel, so it is too late
to call Component.invalidate() or ComponentCtrl.smartUpdate(java.lang.String, java.lang.String) in this method.
Note: ComponentCtrl.onChildAdded(org.zkoss.zk.ui.Component) is called in the request-processing
phase, while ComponentCtrl.onDrawNewChild(org.zkoss.zk.ui.Component, java.lang.StringBuffer) is called in the redrawing phase.
Component developer might do one of the follows:
ComponentCtrl.onDrawNewChild(org.zkoss.zk.ui.Component, java.lang.StringBuffer) to add special tags, if
new child needs to be added an exterior with some tags before
insertion.ComponentCtrl.onChildAdded(org.zkoss.zk.ui.Component) and calls Component.invalidate()
onDrawNewChild in interface ComponentCtrlchild - the child being renderedout - the rendered result of the child.
java.io.IOExceptionprotected boolean isAsapRequired(java.lang.String evtnm)
Default: return true if any non-deferable event listener of
the specified event is found. In other words, it returns
Events.isListened(org.zkoss.zk.ui.Component, java.lang.String, boolean) with asap = true.
This method is moved from HtmlBasedComponent to
AbstractComponent since 3.0.0.
evtnm - the event name, such as onClick
protected java.lang.StringBuffer appendAsapAttr(java.lang.StringBuffer sb,
java.lang.String evtnm)
z.onChange="true".
This method is moved from HtmlBasedComponent to
AbstractComponent since 3.0.0.
sb - the string buffer to hold the HTML attribute. If null and
isAsapRequired(java.lang.String) is true, a string buffer is created and returned.evtnm - the event name, such as onClick
isAsapRequired(java.lang.String)
returns false, null is returned.
If the caller passed non-null sb, the returned value must be the same
as sb (so it usually ignores the returned value).appendAsapAttr(StringBuffer sb, String, boolean)
protected java.lang.StringBuffer appendAsapAttr(java.lang.StringBuffer sb,
java.lang.String evtnm,
boolean enforce)
z.onChange="true".
appendAsapAttr(sb, evtnm) is the same as appendAsapAttr(sb, evtnm, false).
enforce - whether to append the event attribute even if
isAsapRequired(java.lang.String) returns false.
If enforce is false, this method is the same as
appendAsapAttr(StringBuffer, String)
public boolean addEventListener(java.lang.String evtnm,
EventListener 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).
addEventListener in interface Componentevtnm - what event to listen (never null)
Page.addEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener)
public boolean removeEventListener(java.lang.String evtnm,
EventListener listener)
Component
removeEventListener in interface Component
public 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 compoennt,
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)
Component
addForward 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)
Component
addForward 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 oringal 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 oringal 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 Namespace getNamespace()
ComponentExactly one namespace is allocated for each ID space.
For example, if the space owner of this component is the page, then
the returned namespace is the same as Page.getNamespace().
Otherwise, it is the same as the namspace returned by the component
owning this ID space.
Namspace is another part of an ID space. It holds only variables
defined thru Component.setVariable(java.lang.String, java.lang.Object, boolean) (and Namespace.setVariable(java.lang.String, java.lang.Object, boolean).
Note: The namespace doesn't include any variable defined by
executing zscripts. To retrieve them, use Page.getZScriptVariable(java.lang.String).
getNamespace in interface ComponentComponent.getSpaceOwner()
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(java.lang.String, org.zkoss.zk.ui.event.EventListener).
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(java.lang.String, org.zkoss.zk.ui.event.EventListener)public java.util.Iterator getListenerIterator(java.lang.String evtnm)
Component
getListenerIterator 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 elemnt 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 and custom-attributes
defined in the ZUML page (PageDefinition)
and the language definition (LanguageDefinition).
applyProperties in interface Componentpublic ComponentDefinition getDefinition()
Component
getDefinition in interface Componentpublic void setComponentDefinition(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.
setComponentDefinition in interface ComponentCtrlpublic ZScript getEventHandler(java.lang.String evtnm)
ComponentCtrl
getEventHandler in interface ComponentCtrlpublic void addSharedEventHandlerMap(EventHandlerMap evthds)
ComponentCtrl
addSharedEventHandlerMap in interface ComponentCtrlevthds - a map of event handlerpublic java.util.Set getEventHandlerNames()
ComponentCtrl
getEventHandlerNames in interface ComponentCtrl
public void addEventHandler(java.lang.String name,
EventHandler evthd)
ComponentCtrl
addEventHandler in interface ComponentCtrlpublic Annotation getAnnotation(java.lang.String annotName)
ComponentCtrl
getAnnotation in interface ComponentCtrlannotName - the annotation name
public Annotation getAnnotation(java.lang.String propName,
java.lang.String annotName)
ComponentCtrl
getAnnotation in interface ComponentCtrlpropName - the property name, e.g., "value".annotName - the annotation namepublic java.util.Collection getAnnotations()
ComponentCtrl
getAnnotations in interface ComponentCtrlpublic java.util.Collection getAnnotations(java.lang.String propName)
ComponentCtrl
getAnnotations in interface ComponentCtrlpropName - the property name, e.g., "value".public java.util.List getAnnotatedPropertiesBy(java.lang.String annotName)
ComponentCtrl
getAnnotatedPropertiesBy in interface ComponentCtrlpublic java.util.List getAnnotatedProperties()
ComponentCtrl
getAnnotatedProperties in interface ComponentCtrlpublic void addSharedAnnotationMap(AnnotationMap annots)
ComponentCtrl
addSharedAnnotationMap in interface ComponentCtrlannots - a annotation map.
public void addAnnotation(java.lang.String annotName,
java.util.Map annotAttrs)
ComponentCtrlUnlike Java, you can add annotations dynamically, and each component has its own annotations.
addAnnotation in interface ComponentCtrlannotName - the annotation name (never null, nor empty).annotAttrs - a map of attributes, or null if no attribute.
The attribute must be in a pair of strings (String name, String value).
public void addAnnotation(java.lang.String propName,
java.lang.String annotName,
java.util.Map annotAttrs)
ComponentCtrl
addAnnotation in interface ComponentCtrlpropName - the property name (never nul, nor empty).annotName - the annotation name (never null, nor empty).annotAttrs - a map of attributes, or null if no attribute at all.
The attribute must be in a pair of strings (String name, String value).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 ComponentCtrlpublic java.lang.Object getExtraCtrl()
It is simpler to override newExtraCtrl() instead of this.
By use of newExtraCtrl(), you don't need to care of
cloning and serialization.
Default: return the object being created by newExtraCtrl(),
if any.
getExtraCtrl in interface ComponentCtrlCropper
and InputableX.ComponentCtrl.getExtraCtrl()protected java.lang.Object newExtraCtrl()
getExtraCtrl() to create extra controls.
It is used only by component developers.
Default: return null.
To provide extra controls, it is simpler to override this method
instead of getExtraCtrl().
By use of newExtraCtrl(), you don't need to care of
cloning and serialization.
public 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 Command getCommand(java.lang.String cmdId)
AuRequest.getCommand(java.lang.String)
instead.
Default: does nothing but return null.
getCommand in interface ComponentCtrlComponentCommandpublic java.lang.String toString()
toString in class java.lang.Objectpublic final boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic java.lang.Object clone()
Component
clone in interface Componentclone in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||