Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the significance of currentStyle

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.

like image 357
balaji Avatar asked Dec 16 '22 12:12

balaji


2 Answers

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 component 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.

like image 181
rakhi4110 Avatar answered Dec 31 '22 20:12

rakhi4110


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.

like image 26
OmP Avatar answered Dec 31 '22 19:12

OmP