你妹的,Doubleselect标签,用了半天,还没搞清楚怎么回事,求解

CaptainGan 2012-06-10 11:39:32
使用doubleselect标签实现2个下拉框的联动,在自己构建数据的时候,就格式很好的展现。
但是在从数据库中取数据出来展现的时候,总是展现第一级,奶奶的,第二级从来没有出现过,神马原因,我自己都不清楚。

大家帮我找哈原因。

下面贴出关键代码。

从数据库中取数据的方法。

/**
* 获得一级分类列表
* @param enterpId
* @param catelogType
* @return
* @throws Exception
*/
public List<TbCatelog> getFirstCatelogList(int enterpId,int catelogType)throws Exception{
Map<String, Object> argsMap = new HashMap<String, Object>();
argsMap.put("enterpId", enterpId);
argsMap.put("catelogType", catelogType);
return this.getListByQuery("GET_FIRST_CATELOGLIST_BYENTERPID_CATELOGTYPE", argsMap);
}



/**
* 获得二级分类映射对象
* @param catelogType
* @return
* @throws Exception
*/
public Map<Integer, List<TbCatelog>> getSecondCatelogMap(int enterpId,int catelogType) throws Exception{
List<TbCatelog> firstCatelogList = new ArrayList<TbCatelog>();
TbCatelog catelog = new TbCatelog();
catelog.setCatelogid(0);
catelog.setCatelogname("请选择一级分类");
firstCatelogList.add(catelog);
firstCatelogList = this.getFirstCatelogList(enterpId, catelogType);
Map<Integer, List<TbCatelog>> subCatelogMap = new HashMap<Integer, List<TbCatelog>>();
if (firstCatelogList!=null) {
for (TbCatelog tbCatelog : firstCatelogList) {
if (tbCatelog!=null) {
List<TbCatelog> subCatelogList = new ArrayList<TbCatelog>();
TbCatelog subCatelog = new TbCatelog();
subCatelog.setCatelogid(0);
subCatelog.setCatelogname("请选择二级分类");
subCatelogList.add(subCatelog);
subCatelogList = this.getSubCatelogList(tbCatelog.getCatelogid());
subCatelogMap.put(tbCatelog.getCatelogid(), subCatelogList);
}
}
}
return subCatelogMap;
}

下面是Action中加载数据的方法

private List<TbCatelog> selectCatelogList = new ArrayList<TbCatelog>();
private Map<Integer, List<TbCatelog>> mapCatelogMap = new HashMap<Integer, List<TbCatelog>>();
/**
* 加载分类选择数据
* @return
*/
public String loadCatelogSelect(){
if (enterpId!=0) {
try {
//加载一级分类列表
//加载第二级分类列表MAP

selectCatelogList = catelogService.getFirstCatelogList(enterpId, 0);
mapCatelogMap = catelogService.getSecondCatelogMap(enterpId, 0);
return Const.SELECT_OK;
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}



public List<TbCatelog> getSelectCatelogList() {
return selectCatelogList;
}

public void setSelectCatelogList(List<TbCatelog> selectCatelogList) {
this.selectCatelogList = selectCatelogList;
}

public Map<Integer, List<TbCatelog>> getMapCatelogMap() {
return mapCatelogMap;
}

public void setMapCatelogMap(Map<Integer, List<TbCatelog>> mapCatelogMap) {
this.mapCatelogMap = mapCatelogMap;
}




下面是doubleselect的标签填写

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<style>
.doubleselect br {
display: none;
}
</style>
</head>
<body>
<s:form name="doubleSelectForm" action="loadNewsCatelogAction">
<div class="doubleselect">
<s:doubleselect formName="doubleSelectForm" list="selectCatelogList"
listKey="catelogid" listValue="catelogname"
doubleList="mapCatelogMap.get(top.catelogid)" doubleListKey="catelogid"
doubleListValue="catelogname"
doubleName="doubleSelectEntity.subCatelogId" />
</div>
</s:form>
</body>
</html>

...全文
91 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
上帝的无名指 2012-06-11
  • 打赏
  • 举报
回复
贴<s:debug>代码

看你页面能取到什么值

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧