Null check for a value in Sightly in AEM 6.4 | Community
Skip to main content
Level 2
May 27, 2019
Solved

Null check for a value in Sightly in AEM 6.4

  • May 27, 2019
  • 1 reply
  • 4866 views

Hi All,

I have created a component which has a list value being returned from Java. Everytime I author the component the value obtained in the html is null. In the logs it gives a null pointer exception. The values in these fields are coming from tagging in AEM. How do I place a null check condition in the component? PFB the snippet of the code in sightly :

<div data-sly-list.collist="${column.getcolumnList}" data-sly-unwrap>

     <div class="pr-0 pl-0 outer-container ${properties.padding} ${collist.getparentClass}" style="" >

          <div class="inner-container ${collist.getchildClass} ${collist.getCorners}"  style=";border-color:${collist.getBordercolor !=null ? collist.getBordercolor : '' @ context = 'unsafe'}">

             <div data-sly-resource="${ @path=collist.getNumber, resourceType='foundation/components/parsys'}">

           </div>

      </div></div>

Note: I have to add the condition for ${collist.getparentClass} and ${collist.getchildClass}

Arun Patidarsmacdonald2008

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

Hi,

The issue could be, how you are calling methods in sightly. If Java methods have names start with get then no need to use get in sightly.

e.g. Java method - getList() then sightly it should be call like obj.list

and make sure you define method name with proper camel case.

instead of  ${collist.getparentClass} use ${collist.parentClass}

1 reply

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
May 27, 2019

Hi,

The issue could be, how you are calling methods in sightly. If Java methods have names start with get then no need to use get in sightly.

e.g. Java method - getList() then sightly it should be call like obj.list

and make sure you define method name with proper camel case.

instead of  ${collist.getparentClass} use ${collist.parentClass}

Arun Patidar