/*
* Copyright (c) 2012-2032 Accounting Center of China Aviation(ACCA).
* All Rights Reserved.
*/
package com.acca.action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.acca.entity.Area;
import com.acca.service.AreaService;
import com.opensymphony.xwork2.ActionSupport;
/**
*
*
* @version sas-web v1.0
* @author zhouhua, 2013-1-8
*/
@Controller
@Scope("prototype")
public class AreaAction extends ActionSupport {
private Area area;
private Integer parentid=0;
@Resource(name = "areaService")
private AreaService areaService;
private List jsonList = new ArrayList();
/**
* @return the parentid
*/
public Integer getParentid() {
return parentid;
}
/**
* @param parentid the parentid to set
*/
public void setParentid(Integer parentid) {
this.parentid = parentid;
}
/**
* @return the jsonList
*/
public List getJsonList() {
return jsonList;
}
/**
* @param jsonList the jsonList to set
*/
public void setJsonList(List jsonList) {
this.jsonList = jsonList;
}
/**
* @return the area
*/
public Area getArea() {
return area;
}
/**
* @param area the area to set
*/
public void setArea(Area area) {
this.area = area;
}
/**
* @param areaService the areaService to set
*/
public void setAreaService(AreaService areaService) {
this.areaService = areaService;
}
/**
* 形成下拉列表
*
* @return
*/
@SuppressWarnings("unchecked")
public String combox() {
List<Area> list = areaService.findAll(parentid);
for (Area r : list) {
Map map = new HashMap();
map.put("areaid", r.getAreaid());
map.put("name", r.getName());
jsonList.add(map);
}
return SUCCESS;
}
}
package com.acca.action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.acca.entity.Area;
import com.acca.service.AreaService;
import com.opensymphony.xwork2.ActionSupport;
/**
*
*
*
* @author zhouhua, 2013-1-8
*/
@Controller
@Scope("prototype")
public class AreaAction extends ActionSupport {
private Area area;
private Integer parentid=0;
@Resource(name = "areaService")
private AreaService areaService;
private List jsonList = new ArrayList();
/**
* @return the parentid
*/
public Integer getParentid() {
return parentid;
}
/**
* @param parentid the parentid to set
*/
public void setParentid(Integer parentid) {
this.parentid = parentid;
}
/**
* @return the jsonList
*/
public List getJsonList() {
return jsonList;
}
/**
* @param jsonList the jsonList to set
*/
public void setJsonList(List jsonList) {
this.jsonList = jsonList;
}
/**
* @return the area
*/
public Area getArea() {
return area;
}
/**
* @param area the area to set
*/
public void setArea(Area area) {
this.area = area;
}
/**
* @param areaService the areaService to set
*/
public void setAreaService(AreaService areaService) {
this.areaService = areaService;
}
/**
* 形成下拉列表
*
* @return
*/
@SuppressWarnings("unchecked")
public String combox() {
List<Area> list = areaService.findAll(parentid);
for (Area r : list) {
Map map = new HashMap();
map.put("areaid", r.getAreaid());
map.put("name", r.getName());
jsonList.add(map);
}
return SUCCESS;
}
}
package com.acca.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.acca.dao.AreaDao;
import com.acca.entity.Area;
import com.acca.entity.PageModel;
import com.acca.service.AreaService;
/**
*
*
*
* @author zhouhua, 2013-1-8
*/
@Service("areaService")
public class AreaServiceImpl implements AreaService {
@Resource(name="areaDao")
private AreaDao areaDao;
/**
* @param areaDao the areaDao to set
*/
public void setAreaDao(AreaDao areaDao) {
this.areaDao = areaDao;
}
/**
* @return
* @see com.acca.service.impl.AreaService#findAll()
*/
@Override
public List<Area> findAll(Integer parentid) {
return areaDao.findAll(parentid);
}
}
/*
* Copyright (c) 2012-2032 Accounting Center of China Aviation(ACCA).
* All Rights Reserved.
*/
package com.acca.dao.impl;
import java.sql.SQLException;
import java.util.List;
import javax.annotation.Resource;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
import com.acca.dao.AreaDao;
import com.acca.entity.Area;
import com.acca.entity.PageModel;
/**
*
*
* @version sas-web v1.0
* @author zhouhua, 2013-1-8
*/
@Repository("areaDao")
public class AreaDaoImpl extends HibernateDaoSupport implements AreaDao {
private SessionFactory sessionFacotry;
// 注入一个bean, 默认(name = "sessionFactory"), 因此只写@Resource
@Resource
public void setSessionFacotry(SessionFactory sessionFacotry) {
super.setSessionFactory(sessionFacotry);
}
/**
* @return
* @see com.acca.dao.AreaDao#findAll()
*/
@Override
public List<Area> findAll(final Integer parentid) {
@SuppressWarnings("unchecked")
List<Area> list = (List<Area>) getHibernateTemplate().execute(new HibernateCallback() {
@Override
public Object doInHibernate(Session session) throws HibernateException, SQLException {
return session.createQuery("from Area a where a.parentid=? order by a.vieworder")
.setParameter(0, parentid)
.list();
}
});
return list;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<context:component-scan base-package="com.acca"/>
<!-- 配置注解工厂 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
<!-- 扫描实体 -->
<property name="packagesToScan">
<list>
<value>com/acca/entity</value>
</list>
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<!-- 配置事务特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="*" read-only="false"/>
</tx:attributes>
</tx:advice>
<!-- 声明哪些包使用事务 -->
<aop:config>
<aop:pointcut expression="execution(* com.acca.service.*.*(..))" id="allService"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="allService"/>
</aop:config>
</beans>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.multipart.saveDir" value="D:/temp"></constant>
<constant name="struts.devMode" value="true"></constant>
<package name="struts" extends="struts-default,json-default" namespace="/">
<action name="combox" class="areaAction" method="combox">
<result type="json">
<param name="root">jsonList</param>
</result>
</action>
</package>
</struts>
package com.acca.entity;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
/**
*
*
*
* @author zhouhua, 2013-1-8
*/
@Entity
@Table(name="area")
public class Area {
@Id
@GeneratedValue
private Integer areaid;
private String name;
private Integer parentid;
private Integer vieworder;
/**
* @return the areaid
*/
public Integer getAreaid() {
return areaid;
}
/**
* @param areaid the areaid to set
*/
public void setAreaid(Integer areaid) {
this.areaid = areaid;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the parentid
*/
public Integer getParentid() {
return parentid;
}
/**
* @param parentid the parentid to set
*/
public void setParentid(Integer parentid) {
this.parentid = parentid;
}
/**
* @return the vieworder
*/
public Integer getVieworder() {
return vieworder;
}
/**
* @param vieworder the vieworder to set
*/
public void setVieworder(Integer vieworder) {
this.vieworder = vieworder;
}
}
分享到:
相关推荐
Easyui调用数据库实现省市县区三级联动的效果如果下 1、首先要设计数据库,如图所示。一个有4个字段code,note,pycode。code:行政区划代码,note:中文注释,pycode:拼音缩写。 其中code是由6个字段组成。...
省市区的三级联动easyui实现的,里面直接复制代码也就可以了,我自己用着感觉凑合
ssm+mysql+easyui-tree的三级联动,我是将数据拼接后传到前台的,应该还是比较简单易懂的
2018年最新的jquery, easyui, combobox ,mysql,数据库,省市县,三级联动
基于easyui 框架 通过读取json 文件 实现三联动效果,index3.html 是基于jQuery 通过读取json 文件实现省市区三联动效果, index4.html是基于easyui 框架 实现的省市区三联动效果
SSh结合Easyui实现Datagrid的分页显示(多个实例)。这篇写SSh结合Easyui实现Datagrid的分页显示,其他的例如添加、修改、删除、批量删除等功能
//省市区三级联动 $.citySelect({ $province: $('#province'), $city: $('#city'), $County: $('#county') }); $('#ff').form('load', { 'province': '广东省', 'city': '深圳市', 'county': '罗湖区' }); }); <...
easyui+ssh(增删改模糊查询,导出数据),里面已经加了注解需要的可以自行下载学习。
中国省市区三级联的JSON格式,分为3种不同的json数据,用在下拉选择省市区
swfupload结合easyui以及ssh框架实现的文件上传,并且将文件的节本信息存到数据库中
jquery Easyui 动态二级联动
easyui datagrid+SSH集成项目问题总结,史上最清楚的讲解
本篇文章主要介绍了jQuery使用EasyUi实现三级联动效果,实例使用EasyUi实现三级联动技巧,非常具有实用价值,需要的朋友可以参考下。
博客链接:http://blog.csdn.net/yuhuiling/article/details/77315814
自己搜索整理的基于easyUI,jQuery实现的全国城市省市区三级级联选择,在网上查了好多资料,优化整理了一下,分享给大家。。。
通过jquery easyui 实现三级菜单导航栏
省市区js文件,中国省市区js,json文件资源无数字编号