Forum Discussion

bhupen's avatar
bhupen
Advisor
11 years ago

how can setup default value in ftl?

Hi,

 

Iam getting following error:

 

the following has evaluated to null or missing: ==> link [in template "preview" at line 145, column 55] Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>

But Iam not sure how can I setup default value for this. I have the following code where Iam getting this value using FTL:

<#assign link    = notification.target.entity.@view_href />

<a href="${link}">
  <h4>${notification.target.actor.login?string},
  ${text.format('pdc6.notifications.mentioned_string')},                                
  ${subject?string}</h4>
 <div class="details">
  <b class="notification-icon mono-icons-bg notification-mention"></b> ${date}
    </div>
  </a>
              

2 Replies

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)
    11 years ago

    bhupen 

     

    Have you tried:

     

    <#assign link    = notification.target.entity.@view_href />

     

    <#if link??>

      <a href="${link}">

    <#else>

      <a href="http://www.google.com">

    </#if>


      <h4>${notification.target.actor.login?string},
      ${text.format('pdc6.notifications.mentioned_string')},                                
      ${subject?string}</h4>
     <div class="details">
      <b class="notification-icon mono-icons-bg notification-mention"></b> ${date}
        </div>
      </a>

     

    If it doesn't work then the error is with 'notification.target.entity.@view_href /'