如何过滤AEM Granite UI路径浏览器中可见的页面?

ton*_*edz 2 aem

在AEM Classic UI中有一个pathfieldxtype,允许程序员指定一个predicate属性以过滤可选择的页面.

predicate属性的值确定在路径字段中显示哪些页面.有一个数字OOTB的谓词如'hierarchy','folder','hierarchyNotFile'等.

可以通过编写实现org.apache.commons.collections.Predicate该类的OSGi服务来提供自定义谓词.具体而言,通过predicate.name属性的值选择实现.

例如:

@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
    }
}
Run Code Online (Sandbox Code Playgroud)

可以使用以下方式:

<productPath
    jcr:primaryType="cq:Widget"
    allowBlank="false"
    predicate="[productPage]" <-- refers to the OSGi service
    fieldLabel="Product"
    name="./productPath"
    xtype="pathfield"/>
Run Code Online (Sandbox Code Playgroud)

有没有办法在相当于路径字段的Touch UI中实现类似的自定义级别?

我可以看到小部件granite/ui/components/foundation/form/pathbrowser被许多OOTB组件(foundation/components/image以及其他组件)使用.它看起来像是新接口中路径字段的1:1替换.但是,我在AEM 6.2Granite UI文档中找不到任何对它的引用

该字段看起来像这样:

触摸UI对话框中的路径浏览器字段

单击它会显示一个很好的界面,可以选择页面或资源:

路径浏览器字段中的路径选择

如何过滤Touch UI路径浏览器中可用的页面?有没有办法让它使用Predicate以前定义的用于经典UI?

小智 5

在AEM 6.2中,它的工作方式与之前相同,并且可以重用在早期版本中创建的谓词.

你可以在geometrixx中找到例子:

/libs/foundation/components/reference/cq:dialog/content/items/column/items/reference
Run Code Online (Sandbox Code Playgroud)

这是字段定义本身(为了这篇文章的目的,序列化为XML)

<reference
    fieldLabel="Reference"
    jcr:primaryType="nt:unstructured"
    name="./path"
    predicate="nosystem"
    rootPath="/content"
    sling:resourceType="granite/ui/components/foundation/form/pathbrowser" />
Run Code Online (Sandbox Code Playgroud)

您可以在此Geometrixx页面上查看使用此字段的组件的外观:

/content/geometrixx/en/company/bod/jcr:content/par/reference_1
Run Code Online (Sandbox Code Playgroud)