如何过滤 AEM Granite UI 路径浏览器中可见的页面? [英] How to filter the pages visible in an AEM Granite UI Path Browser?
问题描述
在 AEM Classic UI 中有一个
点击它会出现一个漂亮的界面,您可以在其中选择一个页面或资产:
如何过滤触摸 UI 路径浏览器中可用的页面?有没有办法让它使用之前定义的用于经典 UI 的 Predicate
?
在 AEM 6.2 中,这与以前的工作方式相同,并且可以重用早期版本中创建的谓词.
您可以在 geometrixx 中找到示例:
/libs/foundation/components/reference/cq:dialog/content/items/column/items/reference
这是字段定义本身(为了本文的目的,序列化为 XML)
<参考fieldLabel="参考"jcr:primaryType="nt:unstructured"名称="./路径"谓词=无系统"根路径=/内容"吊索:resourceType="granite/ui/components/foundation/form/pathbrowser"/>
您可以在此 Geometrixx 页面上查看使用此字段的组件的外观:
/content/geometrixx/en/company/bod/jcr:content/par/reference_1
In the AEM Classic UI has a pathfield
xtype that allows the programmer to specify a predicate
attribute in order to filter the selectable pages.
The value of the predicate
attribute determines which pages are shown in the pathfield. There is a number of OOTB predicates such as 'hierarchy'
, 'folder'
, 'hierarchyNotFile'
, etc.
One can provide a custom predicate by writing an OSGi service implementing the org.apache.commons.collections.Predicate
class. Specifically, the implementation is selected by the value of the predicate.name
property.
For example:
@Service(Predicate.class)
@Component(metatype = false)
@Properties(@Property(name = "predicate.name", value = "productPage"))
public class ProductPagePredicate extends com.day.cq.commons.predicate.AbstractNodePredicate {
@Override
public boolean evaluate(Node n) {
// return true or false depending on the state of the node
}
}
could be used the following way:
<productPath
jcr:primaryType="cq:Widget"
allowBlank="false"
predicate="[productPage]" <-- refers to the OSGi service
fieldLabel="Product"
name="./productPath"
xtype="pathfield"/>
Is there a way to achieve a similar level of customization in the Touch UI equivalent of the path field?
I can see that the widget granite/ui/components/foundation/form/pathbrowser
is used by a number of OOTB components (foundation/components/image
among others). It looks like a 1:1 replacement of the path field in the new interface. However, I can't find any references to it in the Granite UI documentation for AEM 6.2
The field looks something like this:
Clicking it brings up a nice interface where one can select a page or asset:
How can I filter the pages available in a Touch UI Path Browser? Is there a way to make it use a Predicate
previously defined for use in Classic UI?
In AEM 6.2 this works in the same way as before and predicates created in earlier versions can be reused.
You can find example in geometrixx:
/libs/foundation/components/reference/cq:dialog/content/items/column/items/reference
Here's the field definition itself (serialised to XML for the purpose of this post)
<reference
fieldLabel="Reference"
jcr:primaryType="nt:unstructured"
name="./path"
predicate="nosystem"
rootPath="/content"
sling:resourceType="granite/ui/components/foundation/form/pathbrowser" />
You can see how a component using this field looks on this Geometrixx page:
/content/geometrixx/en/company/bod/jcr:content/par/reference_1
这篇关于如何过滤 AEM Granite UI 路径浏览器中可见的页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!