论坛首页 入门技术论坛

Velocity结合Ajax做的级联菜单,下拉列表

浏览 3490 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2008-08-22  
public ModelAndView admin(HttpServletRequest request,
			HttpServletResponse response) {
		// TODO Auto-generated method stub

		int newsWebSourceID = ReqTools.getReqInt(request, "newsWebSourceID", 0);
		String xAction = ReqTools.getReq(request, "xAction", "");

		int newsChannelID = ReqTools.getReqInt(request, "newsChannelID", 0);
		int pointNum = 0;
		String newsUrl = null;
		String title = null;
		String content = null;
		if (xAction.equals("")) {			
		
			List<NewsWebSource> newsWebSourceList = newsService
					.getAllWebSource();
			List<NewsChannel> newsChannelList = newsService
					.findNewsChannelByWebSiteID(newsWebSourceID);
			Map<Integer, List<NewsChannel>> newsChannelsMapByWebSourceID = newsService
					.getChannelsByWebSourceID();
			Map model = new HashMap();
			model.put("newsWebSourceList", newsWebSourceList);
			model.put("newsChannelList", newsChannelList);
			model.put("newsChannelsMapByWebSourceID",
					newsChannelsMapByWebSourceID);
			model.put("opera", opera);
			model.put("newsWebSourceID", newsWebSourceID);
			model.put("newsChannelID", newsChannelID);
			return new ModelAndView("news/adminNewsCreate", model);
		}
		return null;

	} 

<select id="newsWebSourceID" name="newsWebSourceID" onChange="changeWebSource();"></select>
<select name="newsChannelID" ></select> <script>
function initNewsSelect(){

#foreach($newsWebSource in $newsWebSourceList)
var oOption${velocityCount} = document.createElement("OPTION");
oOption${velocityCount}.text = "$newsWebSource.name";
oOption${velocityCount}.value = "$newsWebSource.newsWebSourceID";
$("newsWebSourceID").add(oOption${velocityCount});


#if($newsWebSource.newsWebSourceID == $newsWebSourceID)
$("newsWebSourceID").value="$newsWebSourceID";
#end


changeWebSource();

#end
}

initNewsSelect();
function   changeWebSource ()
{
$("newsChannelID").innerHTML="";
var selectWebSourceID = $("newsWebSourceID").value;

#foreach($newWebSource in $newsWebSourceList)
if ( selectWebSourceID == $newWebSource.newsWebSourceID)
{
#set($channels = $newsChannelsMapByWebSourceID.get($newWebSource.newsWebSourceID));
#foreach ($channel in  $channels )
{
var oOption${velocityCount} = document.createElement("OPTION");
oOption${velocityCount}.text = "$channel.name";
oOption${velocityCount}.value = "$channel.newsChannelID";
$("newsChannelID").add(oOption${velocityCount});

#if($channel.newsChannelID == $newsChannelID)
$("newsChannelID").value="$newsChannelID";
#end

}
#end
}
#end
}
</script>
 
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics