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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With