0

I am trying to disable a link based on the URL parameter using Struts2 if condition. I don't want to use JavaScript but without it I am not sure how would I get the link and disable it.

Condition is if showReport=false in URL then disable the link.

Form

<s:set name="showDownloadReportLink" value="showReport"/>
<form name="viewIntegrationReport" id="viewIntegrationReport" action="<integration:urlAction actionName='/integration/viewReportIntegration'></integration:urlAction>" method="POST">
    <s:hidden property="createdDays" name="createdDays" value="30"/>
    <s:if test="%{#showDownloadReportLink=='false'}">
        ???
    </s:if>
</form> 

Here is the link in a table

<table>
  <tr>
   <td class="dataFieldCell">
        <div class="downloadReportLink">
              <a href="#x" id="downloadReportId" title="This function will provide you a 30 day download of all your eSign transactions." onclick="document.getElementById('viewIntegrationReport').submit()"><span>Export E-Sign Information</span></a>
        </div> 
    </td> 
  </tr>
</table
Roman C
  • 49,761
  • 33
  • 66
  • 176
Jaykumar
  • 165
  • 1
  • 8
  • 23

1 Answers1

0

You can use CSS to disable the link, like used in this answer: https://stackoverflow.com/a/4416239/3499320

First, create a CSS class for non active links, and, then, inside the s:if you put the class or not to the tag.

Example:

<style>
.not-active {
   pointer-events: none;
   cursor: default;
}
</style>

<s:if test="%{#showDownloadReportLink=='false'}">
   <a href="link.html" class="not-active">Link</a>
</s:if>
<s:else>
   <a href="link.html">Link</a>
</s:else>
Community
  • 1
  • 1
henriquels
  • 518
  • 4
  • 20