Package org.zkoss.zk.ui.ext
Interface Scope
- All Known Implementing Classes:
AbstractComponent,AbstractExecution,AbstractPage,AbstractWebApp,DesktopImpl,ExecutionImpl,HtmlBasedComponent,HtmlMacroComponent,HtmlNativeComponent,HtmlShadowElement,PageImpl,SerializableSession,SimpleScope,SimpleSession,SimpleWebApp,StubComponent,StubsComponent,SynchronizedScope,VolatilePage
public interface Scope
Represents a scope of attributes.
In ZK, directly acquiring a lock on a scope for synchronization is uncommon.
This method Scopes.getLockForScopeIfAny(Scope) provides a reliable way
to obtain a consistent lock object associated with a specific scope, ensuring
that synchronization is consistently managed across different parts of the application.
- Since:
- 3.6.0
- Author:
- tomyeh
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddScopeListener(ScopeListener listener) Adds a listener to listen whether this scope is changed.getAttribute(String name) Returns the custom attribute associated with this object (scope).getAttribute(String name, boolean recurse) Returns the custom attribute associated with this object.Returns all custom attributes associated with this object (scope).booleanhasAttribute(String name) Returns if a custom attribute is associated with this object (scope).booleanhasAttribute(String name, boolean recurse) Returns if a custom attribute is associated with this object.removeAttribute(String name) Removes the attribute from the current scope if any.removeAttribute(String name, boolean recurse) Removes the custom attribute associated with this scope.booleanremoveScopeListener(ScopeListener listener) Removes a change listener from this scope.setAttribute(String name, Object value) Sets (a.k.a., associates) the value for a custom attribute with this object (scope).setAttribute(String name, Object value, boolean recurse) Sets the custom attribute associated with this scope, or the parent scope.
-
Method Details
-
getAttributes
Returns all custom attributes associated with this object (scope). -
getAttribute
Returns the custom attribute associated with this object (scope). -
getAttribute
Returns the custom attribute associated with this object.- Parameters:
recurse- 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.- Since:
- 5.0.0
-
hasAttribute
Returns if a custom attribute is associated with this object (scope).Notice that
nullis a valid value, so you can tell if an attribute is associated by examining the return value ofgetAttribute(java.lang.String).- Since:
- 5.0.0
-
hasAttribute
Returns if a custom attribute is associated with this object.Notice that
nullis a valid value, so you can tell if an attribute is associated by examining the return value ofgetAttribute(java.lang.String).- Parameters:
recurse- 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.- Since:
- 5.0.0
-
setAttribute
Sets (a.k.a., associates) the value for a custom attribute with this object (scope).- Returns:
- the previous value associated with the attribute, if any
- Since:
- 5.0.0
-
setAttribute
Sets the custom attribute associated with this scope, or the parent scope.- Parameters:
recurse- whether to look up the parent scope for the existence of the attribute.
If recurse is true and the attribute is defined in one of its ancestor (including page), the attribute is replaced. Otherwise, it is the same assetAttribute(String,Object).- Since:
- 5.0.0
-
removeAttribute
Removes the attribute from the current scope if any.- Returns:
- the previous value associated with the attribute, if any,
- Since:
- 5.0.0
-
removeAttribute
Removes the custom attribute associated with this scope.- Parameters:
recurse- whether to look up the parent scope for the existence of the attribute.
If recurse is true and the attribute is defined in one of its ancestor (including page), the attribute is removed. Otherwise, it is the same asremoveAttribute(String).- Since:
- 5.0.0
-
addScopeListener
Adds a listener to listen whether this scope is changed. The listener is called when a custom attribute is added, removed, or the parent is changed.- Returns:
- weather the listener is added successfully. Note: if the resolver was added before, it won't be added again and this method returns false.
- Since:
- 5.0.0
-
removeScopeListener
Removes a change listener from this scope.- Returns:
- false if listener is not added before.
- Since:
- 5.0.0
-