Class Components
Component.- Author:
- tomyeh
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.zkoss.zk.ui.Components.ExecExecution Proxystatic final org.zkoss.zk.ui.Components.RequestScopeRequest Scope Proxy -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final StringcomponentToPath(Component comp, Component ref) Converts a component to a path (relevant to another component).static ComposergetComposer(Component comp) Returns the composer object, or null if not found.static PagegetCurrentPage(Component comp) Returns the page of the give component, or the current page if the component is null or it doesn't belong to any page.static final ComponentDefinitiongetDefinitionByDeviceType(String deviceType, Class cls) Returns the component definition of the specified class in all language of the specified device, or null if not foundstatic ObjectgetImplicit(Component comp, String name) Returns the implicit object of the specified name, or null if not found.static ObjectgetImplicit(Page page, String name) Returns the implicit object of the specified name, or null if not found.static ObjectgetImplicit(Page page, Component comp, String name) Returns the implicit object of the specified name, or null if not found.static Collection<String>Returns a readonly collection of the names of the implicit objects.static IdSpacegetParentIdSpace(IdSpace idspace) Returns the parent of the ID space, or null if not found.static ComponentReturns the root component of the specified one.static final intConverts a string to an integer that can be used to accessComponent.getAttribute(String, int)static Collection<Component>getVisibleChildren(Component comp) Returns a collection of visible children.static booleanisAncestor(Component node1, Component node2) Tests whether node1 is an ancestor of node 2.static booleanisImplicit(String id) Returns whether the given id is an implicit ZK object id.static booleanisRealVisible(Component comp) Returns whether this component is real visible (all its parents are visible).static final ComponentpathToComponent(String path, Component ref) Converts a path, generated bycomponentToPath(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component), to a component.static voidremoveAllChildren(Component comp) Removes all children of the specified component.static voidReplaces a component with another.static voidreplaceChildren(Component parent, Collection<Component> newChildren) Replaces all children of the specified component.static final StringscopeToString(int scope) Converts an integer to the string representing the scope.static voidsmartUpdate(Component comp, String key, Object value, boolean append) Adds the smartUpdate command to the specific component.static voidsort(List<? extends Component> list, int from, int to, Comparator<? super Component> cpr) Sorts the components in the list.static voidsort(List<? extends Component> list, Comparator<? super Component> cpr) Sorts the components in the list.
-
Field Details
-
EXECUTION_PROXY
public static final org.zkoss.zk.ui.Components.Exec EXECUTION_PROXYExecution Proxy -
REQUEST_SCOPE_PROXY
public static final org.zkoss.zk.ui.Components.RequestScope REQUEST_SCOPE_PROXYRequest Scope Proxy
-
-
Constructor Details
-
Components
protected Components()
-
-
Method Details
-
getParentIdSpace
Returns the parent of the ID space, or null if not found.- Since:
- 5.0.0
-
sort
Sorts the components in the list.Note: you cannot use
Collections.sort(java.util.List<T>)to sortComponent.getChildren()because Collections.sort might cause some replicated item in the list.- See Also:
-
sort
public static void sort(List<? extends Component> list, int from, int to, Comparator<? super Component> cpr) Sorts the components in the list.- Parameters:
list- the list to be sortedfrom- the index of the first element (inclusive) to be sortedto- the index of the last element (exclusive) to be sortedcpr- the comparator to determine the order of the list.- Since:
- 3.5.0
-
replace
Replaces a component with another.- Parameters:
oldc- the component to remove.newc- the component to add- Throws:
IllegalArgumentException- if oldc's parent and page are both null.- Since:
- 3.5.2
-
replaceChildren
Replaces all children of the specified component. It is the same asparent.getChildren().clear(); parent.getChildren().addAll(newChildren);- Since:
- 3.5.2
-
getRoot
Returns the root component of the specified one. Notice that it could returncomp, if it is already a root component (or it is null).- Since:
- 3.6.3
-
isAncestor
Tests whether node1 is an ancestor of node 2. If node1 and node2 is the same, true is returned. -
removeAllChildren
Removes all children of the specified component. It is the same ascomp.getChildren().clear(). -
getDefinitionByDeviceType
Returns the component definition of the specified class in all language of the specified device, or null if not found- Parameters:
deviceType- the device type (Device), such as ajax. It cannot be null.cls- the implementation class of the component.- Since:
- 5.0.0
-
isRealVisible
Returns whether this component is real visible (all its parents are visible).Note: true is returned if comp is null. In other words, it can be used to examine parent's real visibility even if it is a root component, such as
Components.isRealVisible(getParent()).- See Also:
-
getVisibleChildren
Returns a collection of visible children.The performance of the returned collection's size() is NO GOOD.
-
getScope
Converts a string to an integer that can be used to accessComponent.getAttribute(String, int) -
scopeToString
Converts an integer to the string representing the scope.- Parameters:
scope- one ofComponent.COMPONENT_SCOPE,Component.SPACE_SCOPE,Component.PAGE_SCOPE,Component.DESKTOP_SCOPE,Component.SESSION_SCOPE,Component.REQUEST_SCOPE, andComponent.APPLICATION_SCOPE.
-
componentToPath
Converts a component to a path (relevant to another component). It is usefully to implement a serializable component that contains a reference to another component. In this case, we can not serializes the reference directly (otherwise, another component will be created, when deserialized).Rather, it is better to store the path related, and then restore it back to a component by calling
pathToComponent(java.lang.String, org.zkoss.zk.ui.Component).- Parameters:
comp- the component to be converted to path. It cannot be null.ref- the component used to generated the path from. It cannot be null.- Returns:
- the path. Notice that you have to use
pathToComponent(java.lang.String, org.zkoss.zk.ui.Component)to convert it back. - Throws:
UnsupportedOperationException- if we cannot find a path to the component to write.- Since:
- 3.0.0
-
pathToComponent
Converts a path, generated bycomponentToPath(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component), to a component.- Parameters:
ref- the component used to generated the path from. It cannot be null. It is the same as the one when callingcomponentToPath(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component).- Since:
- 3.0.0
-
isImplicit
Returns whether the given id is an implicit ZK object id.- Parameters:
id- Component id- Returns:
- whether the given name is a implicit object.
- Since:
- 3.5.2
-
getImplicitNames
Returns a readonly collection of the names of the implicit objects.- Since:
- 6.0.0
-
getImplicit
Returns the implicit object of the specified name, or null if not found.Notice that it does check for the current scope (
Scopes.getCurrent(org.zkoss.zk.ui.Page)). Rather,Scopes.getImplicit(java.lang.String, java.lang.Object)depends on this method.- Parameters:
page- the page. If page is null and comp is not, comp.getPage() is assumed- Since:
- 5.0.0
- See Also:
-
getImplicit
Returns the implicit object of the specified name, or null if not found.It is the same as getImplicit(null, comp, name).
- Since:
- 3.6.0
-
getImplicit
Returns the implicit object of the specified name, or null if not found.It is the same as getImplicit(page, null, name).
- Since:
- 3.6.0
-
getComposer
Returns the composer object, or null if not found.- Since:
- 7.0.3
-
smartUpdate
Adds the smartUpdate command to the specific component.- Since:
- 7.0.3
-
getCurrentPage
Returns the page of the give component, or the current page if the component is null or it doesn't belong to any page. The current page is retrieved byExecutionCtrl.getCurrentPage()or the current execution. This method returns null if no execution or no current page at all.- Parameters:
comp- the component to retrieve the page. Ignored if null.- Since:
- 6.0.0
-