在Adobe CQ中将数据从一个组件传递到另一个 [英] Pass data from one component to another in adobe CQ

查看:77
本文介绍了在Adobe CQ中将数据从一个组件传递到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Adobe CQ5。我制作了两个彼此独立的组件。但是,
我想使用另一个组件中一个组件的数据。
如何实现?我该如何使两个组件彼此交互?

I'm using Adobe CQ5. I have made two components that are independent of each other. However, I want to use data from one component in the other one. How do I achieve this? How can I make two components interact with each other?

预先感谢。

推荐答案

您可以使用 javax.jcr.Node javax.jcr.Property 接口获取以下属性另一个组件。例如,您已将component1和component2添加到page1。在存储库中,您应具有类似于以下的结构:

You can use javax.jcr.Node and javax.jcr.Property interface to get properties of another component. For example, you have added component1 and component2 to page1. In the repository you should have structure similar to this:

/content
    /project
        /page1
            /jcr:content
                /parsys
                    /component1
                        /...some properties
                    /component2
                        /...some properties

如果要在component1中获取component2的属性,则可以使用类似的东西:

If you want to get properties of component2 while in component1, you can use something like:

Node parsys = currentNode.getParent();
if(parsys.hasNode("component2")) {
    Node component2 = parsys.getNode("component2");
    if(component2.hasProperty("someProperty"))
      Property someProperty = component2.getProperty("someProperty");
}

这篇关于在Adobe CQ中将数据从一个组件传递到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆