Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Best approach for getting component field values from currentStyle or properties object

Avatar

Level 4

Hi,

 
I have a component with design_dialogue. So in component JSP i access the field values of component via "currentStyle." object and it works great.
 
For example:
currentStyle.heading
currentStyle.imagePath
 
Now I have a requirement that i need the complete <div> of component exposed as JSON for which I am using <c:import>.
But one thing I noticed that when I access the /etc/design node directly using ".html" at end then all the field values are stored in "properties" implict 
 
<c:import var="compDiv1" url="/etc/designs/global/en_US/jcr:content/mySite1/myComp1.html"/>
<c:import var="compDiv2" url="/etc/designs/global/en_US/jcr:content/mySite1/myComp2.html"/>
<c:import var="compDiv3" url="/etc/designs/global/en_US/jcr:content/mySite1/myComp3.html"/>
 
So in JSP i might need to write duplicate code of checking if the variable (or field) value is NOT BLANK in "currentStyle" object then take values from "currentStyle" or object otherwise take from "properties" object.
 
Is there any better way to handle this situation ?
 
Thanks in advance.
1 Accepted Solution

Avatar

Correct answer by
Level 10

This looks like a good way. Check this Stackoverflow thread for more information about this object:

http://stackoverflow.com/questions/15902935/what-is-the-significance-of-currentstyle

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

This looks like a good way. Check this Stackoverflow thread for more information about this object:

http://stackoverflow.com/questions/15902935/what-is-the-significance-of-currentstyle