Sorting Question

"Jinesh Parekh" <[email protected]>
Newsgroups gmane.comp.cms.jahia.template
Message-ID <[email protected]>
Hi

I am trying to sort a glossary container. As soon as I put the sort logic in it, all the contents dissappear instead of sorting. So in short the sorting is not working. Below is the code that I am trying to use.Please advice.

-Jinesh

<%
String glossSort = request.getParameter("glossContainer_sort");
if ( glossSort == null ){System.out.println("RAJAAAAAAAAA");
glossSort = "glossaryTerm"; // By default, no Sort required.
}

String glossSortOrder = request.getParameter("glossContainer_sort_order");
if ( glossSortOrder == null ){
glossSortOrder = "asc"; // By default set to Ascending.
}
if ( !glossSort.equals("none") ){
ContainerSorterBean sorter = new ContainerSorterBean("glossContainer", jParams,glossSort);

// Store the sort handler in the request object.
// It will be used later by the container list loader.
request.setAttribute("glossContainer_sort_handler", sorter);
}
%>

<content:declareContainerList name="glossContainer" title="Glossary container">
<content
:declareContainer>
<content:declareField name="glossaryTerm"
title="Term"
titleKey="term"
bundleKey="<%=resBundleID%>"
type="SharedSmallText"
/>
<content:declareField name="glossaryAcronym"
title="Acronym"
titleKey="acr"
bundleKey="<%=resBundleID%>"

type="SharedSmallText"
/>
<content:declareField name="glossDesc"
title="Description"
titleKey="description"
bundleKey="<%=resBundleID%>"
type="BigText"
/>
</content:declareContainer>
</content:declareContainerList>

<%

int containerID = -1;
try {
containerID = Integer.parseInt(request.getParameter("containerID"));
} catch (NumberFormatException nfe) {
logger.debug("NumberException : " + nfe.toString());
}
%>

<jahia:containerList name="glossContainer" title="Glossary container" windowSize="5">
</jahia:containerList>
<table width="10
0%" border="0" cellspacing="0" cellpadding="2">

<%
String dirPeopleScrollValue = request.getParameter("ctnscroll_glossContainer");
JahiaContainerList glossContainerList = jData.containers().getContainerList( "glossContainer" );
Enumeration glossEnumeration = glossContainerList.getContainers();

int rowColorCount = 0;
String rowColor = "";
int count = 0;

while (glossEnumeration.hasMoreElements()) {
count++;

JahiaContainer glossContainer = (JahiaContainer)glossEnumeration.nextElement();

String glossaryTerm = glossContainer.getFieldValue("glossaryTerm","", true , jData.params());
String glossaryAcronym = glossContainer.getFieldValue("glossaryAcronym","");
S
tring glossDesc = glossContainer.getFieldValue("glossDesc","", true , jData.params());

if (count % 2 == 1){
rowColor = "#ffffff"; // white
} else {
rowColor = "#dddddd"; // grey
}
%>

<%if (count ==1 ){%>
<th align= "left">Glossary Term</th>
<th align= "left">Glossary Acronym</th>
<th align= "left">Glossary Description</th>
<%}//End of if %>

<%

if (count % 2 == 1){
rowColor = "#ffffff"; // white
} else {
rowColor = "#dddddd"
; // grey
}
%>

<tr bgcolor="<%=rowColor%>">
<td valign="top" align = "left"><%=glossaryTerm%></td>
<td valign="top" align = "left"><%=glossaryAcronym%></td>
<td valign="top" align = "left"><%=glossDesc%></td>
<td valign="top" align="right">
<%
if(! jData.gui().html().drawUpdateContainerLauncher( glossContainer ).equals("") ) {
%><a href="javascript:<%= jData.gui().html().drawUpdateContainerLauncher( glossContainer )%>"><%=updateButton%></a><%
}
if (! jData.gui().html().drawDeleteContainerLauncher( glossContainer ).equals("") ){
%>&#160;<a href="j
avascript:<%=jData.gui().html().drawDeleteContainerLauncher( glossContainer )%>"><%=deleteButton%></a><%
}
%>
&#160;</td>
</tr>
<%
}
%>
</table>

<br/>

<jahia:ifEditMode>
<br/><a class="horizontaleline" href="javascript:<%= jData.gui().html().drawAddContainerLauncher( glossContainerList )%>"><%=addButton%>&#160;<jahia:resourceBundle resourceBundle="jahiatemplates.Corporate_portal_templates" resourceName="addItem"/>Add Glossary Item</a><br/>
</jahia:ifEditMode>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.