博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
数据字典统一管理,动态下拉框
阅读量:6265 次
发布时间:2019-06-22

本文共 4587 字,大约阅读时间需要 15 分钟。

前端xhr  js

 

var buildTag = {	/*	 *构建数据字典某一项的下拉框	 */	getInfoTypeDatas:function(selectId,infoCode,defaultValue){		$.get(basePath+"/tag/build!getInfoTypeDatas.action?infoCode="+infoCode,function(arg){			for(var i=0; i
",{ value:arg[i].id, text:arg[i].name }).appendTo($("#"+selectId)); } },"json"); }, /* *选择城市 */ selectCity:function(selectId,defaultValue){ this.getInfoTypeDatas(selectId,"city",defaultValue); }, selectCompanyType:function(selectId,defaultValue){ this.getInfoTypeDatas(selectId,"companyType",defaultValue); }, selectApplicationType:function(selectId,defaultValue){ this.getInfoTypeDatas(selectId,"applicationType",defaultValue); }, /** * feedback type * @param selectId * @param defaultValue */ selectFeedbackType:function(selectId,defaultValue){ this.getInfoTypeDatas(selectId,"feedbacktype",defaultValue); } };

后端java代码

 

action

 

import java.util.List;import javax.annotation.Resource;import com.google.gson.Gson;import cn.com.qytx.cbb.domain.InfoType;import cn.com.qytx.cbb.service.IInfoType;public class BuildTagAction extends BaseAction {	private String infoCode;		@Resource(name="infoTypeImpl")	private IInfoType
infoTypeService; public String getInfoCode() { return infoCode; } public void setInfoCode(String infoCode) { this.infoCode = infoCode; } public String getInfoTypeDatas() throws Exception{ List
list = infoTypeService.findByCode(infoCode); if(list!=null){ Gson gson = new Gson(); ajax(gson.toJson(list)); }else{ ajax(""); } return null; }}

service

 

 

public List
findByCode(String code){ InfoType it = infoTypeDao.findByCode(code); Integer parentId = it.getId(); return infoTypeDao.findSysList(parentId); }

 

java bean

 

public class InfoType extends BaseEntity{	public enum InfoCode{		feedbacktype("feedbacktype");		private InfoCode(String infocode){			this.infocode = infocode;		}		String infocode;		public String getInfoCode(){			return infocode;		}	}	    /**     * 序列号     */    private static final long serialVersionUID = 2669727616436832468L;    @Expose    private String name; // key    private String infoCode; // 值    private Integer recordUserId; // 记录人或最后修改人    private Integer parentId;    private Timestamp createDate;    private Timestamp modifyDate;    public Integer getParentId() {		return parentId;	}	public void setParentId(Integer parentId) {		this.parentId = parentId;	}	public Timestamp getCreateDate() {		return createDate;	}	public void setCreateDate(Timestamp createDate) {		this.createDate = createDate;	}	public Timestamp getModifyDate() {		return modifyDate;	}	public void setModifyDate(Timestamp modifyDate) {		this.modifyDate = modifyDate;	}	public String getName()    {        return this.name;    }    public void setName(String name)    {        this.name = name;    }    public Integer getRecordUserId()    {        return recordUserId;    }    public void setRecordUserId(Integer recordUserId)    {        this.recordUserId = recordUserId;    }	public String getInfoCode() {		return infoCode;	}	public void setInfoCode(String infoCode) {		this.infoCode = infoCode;	}	}

 

util

 

package cn.com.qytx.ayzw.util;import java.util.HashMap;import java.util.Map;import cn.com.qytx.cbb.domain.InfoType;/** * 功能:字典表工具类,单例模式 * 版本: 1.0 * 开发人员:贾永强 * 创建日期: 下午4:40:07  * 修改日期:下午4:40:07  * 修改列表: */public class InfoTypeUtil {		/*******单例模式开始********/	private static InfoTypeUtil instance = null;	private InfoTypeUtil(){			}	public static synchronized InfoTypeUtil getInstance(){		if(instance == null){			instance = new InfoTypeUtil();		}		return instance;	}		/*******单例模式结束********/		private static Map
container = new HashMap
(); /** * 功能: * @param * @return * @throws */ public void putToContainer(Integer id,InfoType infoType){ this.container.put(id, infoType); } public static InfoType getInfoTypeById(int infoTypeId){ return container.get(infoTypeId); } }

 

package cn.com.qytx.ayzw.servlet;import java.util.List;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import cn.com.qytx.ayzw.util.InfoTypeUtil;import cn.com.qytx.cbb.domain.InfoType;import cn.com.qytx.cbb.service.IInfoType;import cn.com.qytx.cbb.util.spring.SpringUtil;public class InitInfoTypeServlet extends HttpServlet {	@Override	public void init() throws ServletException {		// TODO Auto-generated method stub		super.init();		IInfoType
infoTypeService = (IInfoType
) SpringUtil.getBean("infoTypeImpl"); List
list = infoTypeService.findAll(); if(list!=null){ for(int i=0; i

 

转载地址:http://hidpa.baihongyu.com/

你可能感兴趣的文章
kinect sdk开发入门WPFdemo笔记
查看>>
Server.Transfer详细解释
查看>>
java单链表的增、删、查操作
查看>>
The working copy at 'xxx' is too old 错误解决
查看>>
jadclipse
查看>>
// 1.什么是JOSN?
查看>>
SQL语句详细汇总
查看>>
如何保护.net中的dll文件(防破解、反编译)
查看>>
Python 装饰器
查看>>
Docker 网络模式
查看>>
[POI2013]Usuwanka
查看>>
problem-solving-with-algorithms-and-data-structure-usingpython(使用python解决算法和数据结构) -- 算法分析...
查看>>
nodejs + CompoundJS 资源
查看>>
转:C#并口热敏小票打印机打印位图
查看>>
scau 17967 大师姐唱K的固有结界
查看>>
spring之<bean>实例化
查看>>
hereim_美句_2
查看>>
蓝桥杯2017国赛JAVAB组 填字母游戏 题解
查看>>
25.安装配置phantomjs
查看>>
解决sublime3 package control显示There are no packages available for installation
查看>>