Search code examples
javajspdisplaytag

Java displaytag - hide checkbox for particular records


I am using the displaytag in a JSP to show a list of records. The first column contains a checkbox for all records. However, I do not want the checkbox displayed for all records.

I have tried the following, but it continues to display the checkbox for all records. Any ideas?

<display:table id="registered_learners" name="sessionScope.enrolledLearners" decorator="checkboxDecorator" form="displ"
  excludedParams="_chk" pagesize="999">
  <%
  String val = ((LearnerSessionVO) pageContext.getAttribute("registered_learners")).getEmailAddress();
  if (val != null && val.trim() != ""){
  %>
  <display:column style="text-align:center;"  property="checkbox" title="Select for Email" href="javascript:changeSelection('${learners.learnerId}')"/>
  <% } else { %>
  <display:column style="text-align:center;"  title="Select for Email" />
  <% } %>
  <display:column property="lastName" sortable="true"
        title="Last Name" maxLength="25" ></display:column>
 <display:column property="firstName" sortable="true"
        title="First Name"></display:column>
</display:table>

Solution

  • My bad. Simply use the value attribute. For example, using the else statement from above: <display:column style="text-align:center;" title="Select for Email" value="" />