Class FilteringResourceWrapper
- java.lang.Object
-
- org.apache.sling.api.resource.ResourceWrapper
-
- com.adobe.granite.ui.components.FilteringResourceWrapper
-
- Direct Known Subclasses:
WCMFilteringResourceWrapper
public class FilteringResourceWrapper extends ResourceWrapper
A ResourceWrapper that filters its descendant resources based ongranite:hideBooleanEL 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 usegranite:hideproperty.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 = trueAssuming that
my/containerresource type implementation usesFilteringResourceWrapperto wrap its resource (/mycontainerresource),/mycontainer/item2and/mycontainer2/item2will 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
Constructors Constructor Description FilteringResourceWrapper(Resource resource, ExpressionResolver expressionResolver, SlingHttpServletRequest request)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourcegetChild(java.lang.String relPath)Returns the value of callinggetChildon thewrapped resource.java.lang.Iterable<Resource>getChildren()Returns an iterable of the direct children of this resource.java.lang.StringgetResourceType()Returns the value of callinggetResourceTypeon thewrapped resource.booleanhasChildren()Returns the value of callinghasChildrenon thewrapped resource.java.util.Iterator<Resource>listChildren()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 Detail
-
FilteringResourceWrapper
public FilteringResourceWrapper(@Nonnull Resource resource, @Nonnull ExpressionResolver expressionResolver, @Nonnull SlingHttpServletRequest request)
-
-
Method Detail
-
getChild
public Resource getChild(java.lang.String relPath)
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:
ResourceResolver.getResource(Resource, String)
-
listChildren
public java.util.Iterator<Resource> 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:
ResourceResolver.listChildren(Resource)
-
getChildren
public java.lang.Iterable<Resource> 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:
Resource.getChildren()
-
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
public java.lang.String getResourceType()
Description copied from class:ResourceWrapperReturns the value of callinggetResourceTypeon thewrapped resource.- Specified by:
getResourceTypein interfaceResource- Overrides:
getResourceTypein classResourceWrapper- Returns:
- The resource type
-
-