• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Sort & Display Bean Value  RSS feed

 
Jayaram Ponnusamy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I want to sort Bean values in ascending order. By default it is ordering based on the Last Modified time. But I want to Sorting based on Ascending Value (content.subChannels & content.contentInstances). Please help.

<c:if test="${not empty content.contentInstances}">
<c:forEach var="content" items="${content.subChannels}" varStatus="counter">
<templating:contentLink var="linkUrl" oid="${content.system.id}" />
<c:if test="${not empty content.contentInstances}">
<li class="panel" id="dropdown">
<a class="subcat" href="${linkUrl}">${content.system.name}</a>
<a data-toggle="collapse" href="#dropdown-lvl2" class="glyphicon glyphicon-menu-down pull-right"></a>
<div id="dropdown-lvl2" class="panel-collapse collapse">
<div class="panel-body">
<ul class="nav">

<c:if test="${not empty content.contentInstances}">
<c:forEach var="contents" items="${content.contentInstances}" varStatus="counter">
<templating:contentLink var="linkUrl" oid="${contents.system.id}" />
<li><a href="${linkUrl}">${contents.system.name}</a></li>
</c:forEach>
</c:if>

</ul>
</div>
</div>
</li>
</c:if>
</c:forEach>
</c:if>

Thanks
Jay
 
Dave Tolls
Ranch Hand
Posts: 2504
27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would sort the collection before passing it into the JSP.
Since this is not the "natural" order (which seems to be Last Modified Time?), you can write a Comparator to do the sort that you want instead.

If this is from a database then you could sort in the database, but that would involve changing the query.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!