最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - What is the significance of currentStyle - Stack Overflow

programmeradmin1浏览0评论

Can you tell me in CQ5, the exact use of currentStyle.

I have one line like

int absParent = currentStyle.get("absParent", 3);

May I know what currentStyle will do here.

Can you tell me in CQ5, the exact use of currentStyle.

I have one line like

int absParent = currentStyle.get("absParent", 3);

May I know what currentStyle will do here.

Share Improve this question edited Apr 9, 2013 at 13:15 Maroun 96.1k30 gold badges193 silver badges248 bronze badges asked Apr 9, 2013 at 13:13 balajibalaji 7942 gold badges16 silver badges45 bronze badges 2
  • It would seem that it is getting the current style from it's parent element. The current style is a variable that is assigned different values as and when. – Kevin Lynch Commented Apr 9, 2013 at 15:06
  • Thanks Vector,that means it is working in the same way as properties.get(), but it provides the values stored for the property absParent from your design instead of the currentPage,thanks again – balaji Commented Apr 10, 2013 at 1:45
Add a ment  | 

2 Answers 2

Reset to default 9

The currentStyle, an instance of the Style class contains the properties that reflect the design aspect of a cell.

Any change to the properties of a ponent in design mode, gets saved under /etc/designs/<<your project design>> (in case the cq:design property is available for the page or in any of its parent) or /etc/designs/default (the default design), unlike the properties authored in an ordinary dialog, in which case the values are stored under the same page.

Thus, the currentStyle.get(), functions similar to properties.get() as it extends ValueMap, just that it provides you the values stored in the design instead of the content.

There isn't much information available related to this in the docs. However you can take a look at the Designer to understand it further.

In simple plain words currentStyle.get() is used when you want to get data from design_dialog and properties.get() is used when you are getting it from a dialog.

Note: data in design_dialog is global for the template, which means you can access it anywhere in the template by just using currentStyle.get() and you don't need to setAttribute(), where as in dialog the data is stored locally in the page properties.

发布评论

评论列表(0)

  1. 暂无评论