显示结果排序


显示结果排序

<td width="9%" style="text-align: center;cursor:hand;"  onclick="doSorting('airlineCode');">
	<span T:values="@TW航班@@CN航班@@ENAirline@"></span>
	<script type="text/javascript">showIcon("airlineCode");</script>
</td>
<td width="17%" style="text-align: center;cursor:hand;" onclick="doSorting('name');">
	<span T:values="@TW區域名稱(英文)@@CN区域名称(英文)@@ENName(English)@"></span>
	<script type="text/javascript">showIcon("name");</script>
</td>

 <html:hidden property="sortBy" styleId="sortBy"/>

<html:hidden property="ascOrDesc" styleId="ascOrDesc"/>
function doSorting(sortname){
		var sortBy = $("sortBy").value;
		var ascOrDesc  = $("ascOrDesc").value;
		
		if(sortBy == sortname){
			ascOrDesc = (ascOrDesc == "asc" ? "desc" : "asc");
		}else{
			ascOrDesc = "asc";
		}
		$("sortBy").value = sortname;
		$("ascOrDesc").value = ascOrDesc;
		$("doAction").value = "sort";
		processing();
		document.forms[0].submit();
	}
	function showIcon(sortname){
		var icon = $("ascOrDesc").value;
		if($("sortBy").value == sortname){
			document.write("<img src='../images/"+icon+".gif'></img>");
		}
	}
 
JAVA:
else if("sort".equalsIgnoreCase(action)){
			String sortBy = zonesForm.getString("sortBy");
			String ascOrDesc = zonesForm.getString("ascOrDesc");
			Order order = null;
			if("asc".equals(ascOrDesc)){
				order = Order.asc(sortBy);
			}else{
				order = Order.desc(sortBy);
			}
			map.put("order", order);
		}
 org.hibernate.criterion.Order


Order order = (Order) map.get("order");
if(order != null){
	detachedCriteria.addOrder(order);
}else{
	detachedCriteria.addOrder(Order.asc("internalId"));
}
 
。。。


 

你可能感兴趣的:(排序)