My experience has been that you can't really do what you want based on a value 
that varies row-by-row. The <column> tag is more "global" than that, because it 
defines the columns the table will have for ALL rows.

In several of my JSPs, I have conditional logic inside the BODY of the <column> 
tag to determine what, if anything, to display for a specific row. For example 
(assuming you use EL):

<display:table id="row_rec" ...>

   ...

   <display:column title="COL1" sortable="true">  <===== NOTE: No 'property' 
attribute
      <core:choose>
         <core:when test="${row_rec.show_col1}">
            <core:out value="${row_rec.col1}" />
         </core:when>
         <core:otherwise>
            &nbsp;
         </core:otherwise>
      </core:choose>
   </display:column>

   ...

</display:table>

On the other hand...if you want to conditionally display the column based on 
the value of a scoped attribute (i.e., NOT part of the row data), you CAN put 
the <column> tag inside JSP logic tags. For example:

<display:table id="row_rec" ...>

   ...

   <core:if test="${displayColumn1}">
      <display:column property="col1" title="COL1" sortable="true" />
   </core:if>

   ...

</display:table>

I hope this helps.

--John D.

John J. DiLeo, D.Sc.
USDA TAAF Development Lead
Echota Technologies Corp.
Office: (816) 823-5395
Mobile: (816) 803-2678
This message (and any attachments) may contain sensitive (Privacy Act 
Protected) data as defined in FSA IRM-371. It is your responsibility to adhere 
to FSA policies and notices in the internal use and protection of sensitive 
data. If you authorize the release of this information to other government 
entities for official business purposes you must ensure the recipient is 
notified that the data is sensitive and that the recipient must be responsible 
for securing and protecting the data.

-----Original Message-----
From: Emi Lu [mailto:em...@encs.concordia.ca] 
Sent: Friday, January 21, 2011 2:32 PM
To: displaytag-user@lists.sourceforge.net
Subject: [displaytag-user] If logic to dynamic decide whether to display a 
column

Good afternoon,

Need help about using "if logic" to determine whether to display a 
column under display:table

For example:

<display:table id="row_rec"
                name="alist_paging_bean"
                export="true"
                class="simple"
                cellspacing="0"
                cellpadding="5"
                requestURI="ProcessAction"
                keepStatus="true"
                pagesize="<%=bean_display.getPageSize() %>"
                partialList="true"
                size="<%=bean_display.getTotalRecNum() %>"
                defaultorder="ascending"
                defaultsort="1"
 >

Need sth like:
======================
if %{#attr.row_rec.show_col1}
    <display:column property="col1" title="COL1" sortable="true" />

Otherwise, do not display "col1".

What is the grammer of "if %{#attr.row_rec.show_col1}" in jsp please?

In the Bean.java,
private boolean show_rec1;


Thanks a lot!
--
Lu Ying

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to