1
#{if adsonuiAssetList.size()>0}
    #{list items:adsonuiAssetList, as:'adsonui'}
        <div class="imageElement">
            <h3>Asset : ${adsonui?.productname}(${adsonui?.AssetId})&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Advertiser : ${adsonui?.campaign.advertiser.contact_person}(${adsonui?.campaign.advertiser.id})</h3>
            <p></p>
            <a href="@{Assets.showAssetDetails()}?assetid=${adsonui?.AssetId}"  title="${adsonui?.productname}" class="open"></a>
            <img src="@{Assets.getAssetFileForSlideShow(adsonui?.AssetId,adsonui?.campaign?.mode_of_advertisement,870,240)}"  alt="${adsonui?.productname}" class="full" />
            <img src="@{Assets.getAssetFileForSlideShow(adsonui?.AssetId,adsonui?.campaign?.mode_of_advertisement,150,150)}"  alt="${adsonui?.productname}" class="thumbnail" />
    </div>
    #{/list}
#{/if}

Can any one explain ${adsonui?.productname} what will be the ?.stands for please i am new to groovy and play framework pelase tell me what it is exactly doing.

Michael Zajac
  • 55,144
  • 7
  • 113
  • 138
satish
  • 45
  • 5

2 Answers2

1

${adsonui?.productname} will return adsonui.productname if adsonui is not null.

Or null if it is null.

It's called the Safe-Navigation Operator

tim_yates
  • 167,322
  • 27
  • 342
  • 338
1

? enables to avoid the NPE exception in case that foo is null.

see axample - the first println gives null the second fails

def foo

println foo?.bar

null

println foo.bar

Caught: java.lang.NullPointerException: Cannot get property 'bar' on null object 

I.e. you need not to test if foo is null and decide if you can reference bar

Marmite Bomber
  • 19,886
  • 4
  • 26
  • 53