Class FilteringResourceWrapper
- Direct Known Subclasses:
WCMFilteringResourceWrapper
granite:hide BooleanEL property.
This wrapper needs to be applied to the container resource, such as the page root resource, and the dialog root resource.
It is also smart enough to handle include component. In that case, if the
resource type is granite/ui/components/coral/foundation/include, the
included resource will also be wrapped by this class, allowing the descendant
resources of the included resource to use granite:hide property.
For example given the following content structure:
+ /mycontainer
- sling:resourceType = "my/container"
+ item1
- sling:resourceType = "my/item"
+ item2
- sling:resourceType = "my/item"
- granite:hide = true
+ item3
- sling:resourceType = "my/item"
+ item4
- sling:resourceType = "granite/ui/components/coral/foundation/include"
- path = "/mycontainer2"
+ /mycontainer2
- sling:resourceType = "my/container2"
+ item1
- sling:resourceType = "my/item"
+ item2
- sling:resourceType = "my/item"
- granite:hide = true
Assuming that my/container resource type implementation uses
FilteringResourceWrapper to wrap its resource (/mycontainer
resource), /mycontainer/item2 and /mycontainer2/item2 will be
excluded during traversal transparently, as if they are not there in the
first place.
-
Field Summary
Fields inherited from interface org.apache.sling.api.resource.Resource
RESOURCE_TYPE_NON_EXISTING -
Constructor Summary
ConstructorsConstructorDescriptionFilteringResourceWrapper(Resource resource, ExpressionResolver expressionResolver, SlingHttpServletRequest request) -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of callinggetChildon thewrapped resource.Returns an iterable of the direct children of this resource.Returns the value of callinggetResourceTypeon thewrapped resource.booleanReturns the value of callinghasChildrenon thewrapped resource.Returns the value of callinglistChildrenon thewrapped resource.Methods inherited from class org.apache.sling.api.resource.ResourceWrapper
adaptTo, getName, getParent, getPath, getResource, getResourceMetadata, getResourceResolver, getResourceSuperType, getValueMap, isResourceType, toString
-
Constructor Details
-
FilteringResourceWrapper
public FilteringResourceWrapper(@Nonnull Resource resource, @Nonnull ExpressionResolver expressionResolver, @Nonnull SlingHttpServletRequest request)
-
-
Method Details
-
getChild
Description copied from class:ResourceWrapperReturns the value of callinggetChildon thewrapped resource.- Specified by:
getChildin interfaceResource- Overrides:
getChildin classResourceWrapper- Parameters:
relPath- relative path to the child resource- Returns:
- The child resource or
null - See Also:
-
listChildren
Description copied from class:ResourceWrapperReturns the value of callinglistChildrenon thewrapped resource.- Specified by:
listChildrenin interfaceResource- Overrides:
listChildrenin classResourceWrapper- Returns:
- An iterator for child resources.
- See Also:
-
getChildren
Description copied from interface:ResourceReturns an iterable of the direct children of this resource.This method is a convenience and returns exactly the same resources as calling
getResourceResolver().getChildren(resource).- Specified by:
getChildrenin interfaceResource- Overrides:
getChildrenin classResourceWrapper- Returns:
- An iterable for child resources
- See Also:
-
hasChildren
public boolean hasChildren()Description copied from class:ResourceWrapperReturns the value of callinghasChildrenon thewrapped resource.- Specified by:
hasChildrenin interfaceResource- Overrides:
hasChildrenin classResourceWrapper- Returns:
trueif the resource has any child resources
-
getResourceType
Description copied from class:ResourceWrapperReturns the value of callinggetResourceTypeon thewrapped resource.- Specified by:
getResourceTypein interfaceResource- Overrides:
getResourceTypein classResourceWrapper- Returns:
- The resource type
-