- 浏览: 420453 次
- 性别:
- 来自: 郑州
-
文章分类
最新评论
-
yan789654100:
先谢谢了,去研究一下
Java网络围棋游戏源码含大厅,仿QQ游戏 -
dan0773:
火狐里面用不了
梅花雨日历控件源码,及应用实例 -
左手边:
挺好的不错
Velocity教程 -
liuxuejin:
既然是教程,连个例子都没有!顶多是个笔记而已
Velocity教程 -
sky_pearl:
泪奔……求大厅代码!!!
Java网络围棋游戏源码含大厅,仿QQ游戏
jmesa 使用指南
1、关于jmesa
开始搭建新的基于struts2+spring+hibernate的技术架构,基于以前对eXtremeTable的好感,决定继续采用extremetable,而不选用displaytag和valuelist。用google搜索发现eXtremeTable的作者己不再更新eXtremeTable,其把精力转移到了新的项目-JMesa。
However, now that JMesa is up to release 2.1 I am only focusing my efforts on that library. The JMesa API has really turned into the library I have always wanted to create. With the introduction of the tags and facade in release 2.1 building tables is now easier than ever. I would encourage developers that are able to run in a JDK1.5 and JSP2.0 container to start using JMesa. If you are interested in a full explanation about how JMesa came about you can read more on the JMesa site. If you are more interested in what JMesa offers over the eXtremeTable read the features list.
2、基于struts2+spring+hibernate+jquery的jmesa分页实现样例
2.1、需求场景
基于Jmesa,从数据库表Person中查询出记录,能够实现分页、排序、导出功能。同时结合Jquery,利用ajax实现对数据的删除操作。
2.2、环境说明
Jmesa: 2.3
Struts2 :2.0.11
Spring:2.5
Hibernate:3.2.5
Jquery:jquery-1.2.1.pack,jquery.bgiframe.pack
Tomcat:5.5
Mysql :5.0
数据库、页面、JVM编码统一为GBK
2.3、数据库表结构
CREATE TABLE `person` ( `id` int(10) unsigned NOT NULL auto_increment, `firstName` varchar(45) NOT NULL, `lastName` varchar(45) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=76 DEFAULT CHARSET=latin1;
2.4、页面list.jsp
<%@ taglib prefix="s" uri="/struts-tags"%> <%@ page language="java" errorPage="/error.jsp" pageEncoding="GBK" contentType="text/html;charset=GBK" %> <html> <head> <link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/web.css"></link> <link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/jmesa.css"></link> <!-- 对jmesa.js脚本的应用必须放到头部,而不能放到尾部 --> <script type="text/javascript" src="<%= request.getContextPath() %>/js/jmesa.js"></script> </head> <body> <p>Jmesa表单组件使用演示样例</p> <form name="personForm" action="<%= request.getContextPath() %>/list.action" method="post"> <div id="persons"> <% out.println(request.getAttribute("myhtml")); %> </div> </form> <script type="text/javascript"> function onInvokeAction(id) { setExportToLimit(id, ''); createHiddenInputFieldsForLimitAndSubmit(id); } function onInvokeExportAction(id) { var parameterString = createParameterStringForLimit(id); location.href = '<%= request.getContextPath() %>/list.action?' + parameterString; } function delUser(tableId,rowId) { var parameterString = createParameterStringForLimit(tableId); $.get("<%= request.getContextPath() %>/ajax.action?id="+rowId+"&"+parameterString, function(data) { $("#persons").html(data) }); } </script> <script type="text/javascript" src="<%= request.getContextPath() %>/js/jquery-1.2.1.pack.js"></script> <script type="text/javascript" src="<%= request.getContextPath() %>/js/jquery.bgiframe.pack.js"></script> </body> </html>
2.4、Action代码
package com.mobilesoft.esales.webapp.action; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest; import jxl.demo.CSV; import org.apache.commons.beanutils.BeanUtils; import org.jmesa.facade.TableFacade; import org.jmesa.facade.TableFacadeImpl; import org.jmesa.limit.Limit; import com.mobilesoft.esales.dao.hibernate.Person; import com.mobilesoft.esales.service.PersonService; import com.octo.captcha.service.CaptchaServiceException; import com.opensymphony.xwork2.Action; import static org.jmesa.limit.ExportType.CSV; import static org.jmesa.limit.ExportType.JEXCEL; import static org.jmesa.limit.ExportType.PDF; import org.jmesa.core.filter.DateFilterMatcher; import org.jmesa.core.filter.MatcherKey; import org.jmesa.facade.TableFacade; import org.jmesa.facade.TableFacadeImpl; import org.jmesa.limit.Limit; import org.jmesa.util.ItemUtils; import org.jmesa.view.component.Column; import org.jmesa.view.component.Row; import org.jmesa.view.component.Table; import org.jmesa.view.editor.BasicCellEditor; import org.jmesa.view.editor.CellEditor; import org.jmesa.view.editor.DateCellEditor; import org.jmesa.view.html.HtmlBuilder; import org.jmesa.view.html.component.HtmlColumn; import org.jmesa.view.html.component.HtmlRow; import org.jmesa.view.html.component.HtmlTable; import org.jmesa.view.html.editor.DroplistFilterEditor; import sun.text.CompactShortArray.Iterator; /** * 用于演示基于jmesa(http://code.google.com/p/jmesa/)的分页、排序组件的使用方法, * 在src/java/com/mobilesoft/esales/dao/hibernate/person.sql有Person表的测试数据 * @author <a href="mailto:liangchuan@mobile-soft.cn">liangchuan</a> * @since 2008-03 */ public class PersonAction extends BaseAction { private PersonService personService; private List<Person> persons; private Person person; private Integer id; private String tableId; public String execute() { this.persons = personService.findAll(); //创建id为tableId为表单 //<table id="tableId" border="0" cellpadding="0" cellspacing="0" class="table" width="600px" > TableFacade tableFacade = new TableFacadeImpl("tableId", getRequest()); //设定页面分页数据 tableFacade.setItems(persons); //设定支持的查询结果导出格式为csv,excel,pdf格式 tableFacade.setExportTypes(getResponse(), CSV, JEXCEL, PDF); tableFacade.setStateAttr("restore"); Limit limit = tableFacade.getLimit(); if (limit.isExported()) { export(tableFacade); return null; } else { String html = html(tableFacade); getRequest().setAttribute("myhtml", html); } return Action.SUCCESS; } private String html(TableFacade tableFacade) { // 设定表格属性,注意此处的url用于诸如增加、删除、修改、查询操作,并不是实际的数据库表属性, //但表单需要有对应的po对新,因此需要在Person中增加此属性 tableFacade.setColumnProperties("id", "firstName", "lastName", "url"); HtmlTable table = (HtmlTable) tableFacade.getTable(); table.setCaption("测试用户信息列表"); table.getTableRenderer().setWidth("600px"); HtmlRow row = table.getRow(); HtmlColumn id = row.getColumn("id"); id.setTitle("id"); HtmlColumn firstName = row.getColumn("firstName"); firstName.setTitle("属性1"); HtmlColumn lastName = row.getColumn("lastName"); lastName.setTitle("属性2"); HtmlColumn deleteAction = row.getColumn("url"); deleteAction.setTitle("操作"); // Using an anonymous class to implement a custom editor. // 用于演示在表格中增加超链接 firstName.getCellRenderer().setCellEditor(new CellEditor() { public Object getValue(Object item, String property, int rowcount) { Object value = new BasicCellEditor().getValue(item, property, rowcount); HtmlBuilder html = new HtmlBuilder(); html.a().href().quote().append("http://www.mobile-soft.cn") .quote().close(); html.append(value); html.aEnd(); return html.toString(); } }); // Using an anonymous class to implement a custom editor. //用于演示在表格中增加javascript操作,通过jquery来实现ajax式的删除操作 deleteAction.getCellRenderer().setCellEditor(new CellEditor() { public Object getValue(Object item, String property, int rowcount) { Object value = new BasicCellEditor().getValue(item, property, rowcount); HtmlBuilder html = new HtmlBuilder(); //取得每一行的id号 Object id = ItemUtils.getItemValue(item, "id"); String js=" onclick='javascript:del(\"tableId\","+id+") '"; html.a().append(js).href().quote().append(getRequest().getContextPath()+"/remove.action?id="+id).quote().close(); html.append("删除"); html.aEnd(); return html.toString(); } }); return tableFacade.render(); // Return the Html. } private void export(TableFacade tableFacade) { tableFacade.setColumnProperties("id", "firstName", "lastName"); Table table = tableFacade.getTable(); table.setCaption("Persons Test"); Row row = table.getRow(); Column id = row.getColumn("id"); id.setTitle("id"); Column firstName = row.getColumn("firstName"); firstName.setTitle("First Name"); Column lastName = row.getColumn("lastName"); lastName.setTitle("Last Name"); tableFacade.render(); } public String login() { Boolean isResponseCorrect = Boolean.FALSE; // remenber that we need an id to validate! String captchaId = getSession().getId(); // retrieve the response String response = getRequest().getParameter("j_captcha_response"); // Call the Service method try { isResponseCorrect = CaptchaServiceSingleton.getInstance() .validateResponseForID(captchaId, response); } catch (CaptchaServiceException e) { // should not happen, may be thrown if the id is not valid } if (!isResponseCorrect) { return Action.LOGIN; } return execute(); } public String save() { this.personService.save(person); this.person = new Person(); return execute(); } /** * 用于演示ajax方式删除操作,参看pages/list.jsp * @return */ public String remove() { String deleteId = getRequest().getParameter("id"); if (deleteId != null) { personService.remove(Integer.parseInt(deleteId)); } this.persons = personService.findAll(); TableFacade tableFacade = new TableFacadeImpl("tableId", getRequest()); tableFacade.setItems(persons); // set the items tableFacade.setExportTypes(getResponse(), CSV, JEXCEL, PDF); tableFacade.setStateAttr("restore"); Limit limit = tableFacade.getLimit(); if (limit.isExported()) { export(tableFacade); return null; } else { String html = html(tableFacade); getRequest().setAttribute("myhtml", html); } return Action.SUCCESS; } public List<Person> getPersons() { return persons; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public void prepare() throws Exception { if (id != null) person = personService.find(id); } public Person getPerson() { return person; } public void setPerson(Person person) { this.person = person; } /** * @return the personService */ public PersonService getPersonService() { return personService; } /** * @param personService * the personService to set */ public void setPersonService(PersonService personService) { this.personService = personService; } /** * @return the tableId */ public String getTableId() { return tableId; } /** * @param tableId * the tableId to set */ public void setTableId(String tableId) { this.tableId = tableId; } }
2.5、Service、DAO层代码
无特别的,省略
2.6、Model代码
package com.mobilesoft.esales.dao.hibernate; /** * Person entity. * * @author <a href="mailto:liangchuan@mobile-soft.cn">liangchuan</a>
*/ public class Person implements java.io.Serializable { // Fields private Integer id; private String firstName; private String lastName; private String url=""; // Constructors /** default constructor */ public Person() { } /** full constructor */ public Person(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } // Property accessors public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } public String getFirstName() { return this.firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return this.lastName; } public void setLastName(String lastName) { this.lastName = lastName; } /** * @return the url */ public String getUrl() { return url; } /** * @param url the url to set */ public void setUrl(String url) { this.url = url; } }
2.7、Struts.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.objectFactory" value="spring"/> <constant name="struts.devMode" value="true"/> <constant name="struts.i18n.encoding" value="GBK"/> <constant name="struts.action.extension" value="action"/> <constant name="struts.custom.i18n.resources" value="ApplicationResources,errors"/> <constant name="struts.multipart.maxSize" value="2097152"/> <constant name="struts.multipart.saveDir" value="/resources"/> <constant name="struts.ui.theme" value="css_xhtml"/> <constant name="struts.enable.SlashesInActionNames" value="true"/> <package name="person" extends="struts-default"> <interceptors> <!-- Copied from struts-default.xml and changed validation exclude methods --> <interceptor-stack name="defaultStack"> <interceptor-ref name="exception"/> <interceptor-ref name="alias"/> <interceptor-ref name="servlet-config"/> <interceptor-ref name="prepare"/> <interceptor-ref name="i18n"/> <interceptor-ref name="chain"/> <interceptor-ref name="debugging"/> <interceptor-ref name="profiling"/> <interceptor-ref name="scoped-model-driven"/> <interceptor-ref name="model-driven"/> <interceptor-ref name="fileUpload"/> <interceptor-ref name="checkbox"/> <interceptor-ref name="static-params"/> <interceptor-ref name="params"> <param name="excludeParams">dojo\..*</param> </interceptor-ref> <interceptor-ref name="conversionError"/> <interceptor-ref name="validation"> <param name="excludeMethods">cancel,execute,delete,edit,list</param> </interceptor-ref> <interceptor-ref name="workflow"> <param name="excludeMethods">input,back,cancel,browse</param> </interceptor-ref> </interceptor-stack> <interceptor-stack name="fileUploadStack"> <interceptor-ref name="fileUpload"/> <interceptor-ref name="defaultStack"/> </interceptor-stack> </interceptors> <global-results> <result name="mainMenu" type="redirect">mainMenu.html</result> <result name="dataAccessFailure">pages/dataAccessFailure.jsp</result> </global-results> <global-exception-mappings> <exception-mapping exception="org.springframework.dao.DataAccessException" result="dataAccessFailure"/> </global-exception-mappings> <action name="list" method="execute" class="personAction"> <result name="success">pages/list.jsp</result> <result name="input">pages/list.jsp</result> </action> <action name="remove" class="personAction" method="remove"> <result name="success">pages/list.jsp</result> <result name="input">pages/list.jsp</result> </action> <action name="save" class="personAction" method="save"> <result name="success">pages/list.jsp</result> <result name="input">pages/list.jsp</result> </action> <action name="login" class="personAction" method="execute"> <result name="success">pages/list.jsp</result> <result name="login">/index.jsp</result> </action> <action name="uploadFile" class="com.mobilesoft.esales.webapp.action.FileUploadAction"> <interceptor-ref name="fileUploadStack"/> <result name="input">pages/uploadForm.jsp</result> <result name="success">pages/uploadDisplay.jsp</result> <result name="cancel" type="redirect">/index.jsp</result> </action> </package> </struts>
3、jmesa研究
<TBC>
4、参考资料
http://code.google.com/p/jmesa/w/list
http://blog.csdn.net/jockCreate/archive/2008/02/20/2110310.aspx
http://blog.csdn.net/czg18596/archive/2007/09/06/1774827.aspx
发表评论
-
Extjs 验证使用
2012-08-10 10:16 1025/** * 用户表单面板 */ Ext.def ... -
使用ext的store.load 之后然后使用store.getCount 值为零解决办法
2012-07-13 09:12 1272使用ext的store.load(),之后然后使用store. ... -
什么样的cms系统算是强大
2012-07-10 17:41 1011现在建站的cms系统层出不穷。从简单的到功能复杂的。从功 ... -
OpenCV背景去除的几种方法(转)
2012-07-02 10:15 8644OpenCV背景去除的几种方法 1、肤色侦测法 肤 ... -
error: command 'mt.exe' failed with exit status 31
2012-06-18 17:39 2466python setup.py build_ext -i ... -
MyBatis 3 + Spring3 多数据源配置
2012-02-27 14:50 1405详细内容地址: 终于把 MyBatis 3 和 Sp ... -
Google Earth 开发示例(Hello World)
2011-04-13 17:06 1663Google Earth Hello World 示例 &l ... -
DB2 分页查询方法,查询top N 条记录
2011-01-13 18:50 28571. db2分页查询sql select * f ... -
Birt 中的通过Script加入调试输出SQL语句代码
2010-11-18 15:54 1436用Brit制作报表时可通过在Script脚本中加入以下代码输出 ... -
TSM - Creating an include-exclude list (optional)
2010-06-09 11:00 1583Creating an include-exclude l ... -
TSM - Configuring the Web client
2010-06-09 10:51 963Configuring the Web client The ... -
Linux下 Tsm 服务器、客户端安装配置全过程
2010-05-17 10:06 1780系统环境:LINUX AS5 存储:IBM DS400 ... -
安装DB2补丁步骤
2009-10-27 17:30 17921. 通过运行 su - root ... -
WAS 6.0.2.9 部署应用使用过滤器问题解决办法
2009-08-05 16:07 1477支撑环境: IBM WebSphere Application ... -
MyEclipse5.5GA配置Websphere V6.1 全过程(详细版)
2009-07-16 13:32 1315转载自:http://blog.chinaunix.net/u ... -
WebSphere Application Server 6.0.2.9 配置 SqlServer 2000 SP2时出错问题解决
2009-07-15 12:56 1887WebSphere Application Server 6. ... -
WAS 5.1 部署应用容器属性配置
2009-07-07 14:52 2590WAS 5.1 部署应用容器属性配置 引用地址:http:/ ... -
Struts JSR168 Portlet using the ITIM API
2009-06-02 19:29 1002Leveraging the IBM Tivoli Ident ... -
ITIM API
2009-06-02 19:22 962ITIM API http://publib.boulder ... -
打开IBM WebSphere Portal trace 收集
2009-05-26 10:37 1449Collecting login-specific infor ...
相关推荐
本文将分享在Struts2环境中成功使用Jmesa的经验和心得。 首先,我们需要了解基础环境配置。本例中使用的Struts2版本为2.0.11,Spring为2.5.1,Freemarker为2.3.12,而Jmesa则是2.2.9。开发环境选用的是Eclipse 3.3...
使用JMesa进行分页处理 JMesa是一个更为强大的分页工具,不仅支持基本的分页功能,还提供了排序、过滤等高级特性。 #### 7.2. 分步提交 对于复杂的表单,分步提交是一种很好的用户体验设计。Stripes通过一系列...
mmexport1746490103849.jpg
scratch少儿编程逻辑思维游戏源码-纸片马里奥:撕裂现实 v0.0.8.zip
scratch少儿编程逻辑思维游戏源码-小型杯头人游戏引擎.zip
内容概要:本文详细介绍了一种基于西门子S7-200和S7-300 PLC以及组态王软件的三泵变频恒压供水系统。主要内容涵盖IO分配、接线图原理图、梯形图程序编写和组态画面设计四个方面。通过合理的硬件配置和精确的编程逻辑,确保系统能够在不同负载情况下保持稳定的供水压力,同时实现节能和延长设备使用寿命的目标。 适合人群:从事工业自动化领域的工程师和技术人员,尤其是熟悉PLC编程和组态软件使用的专业人士。 使用场景及目标:适用于需要稳定供水的各种场合,如住宅小区、工厂等。目标是通过优化控制系统,提升供水效率,减少能源消耗,并确保系统的可靠性和安全性。 其他说明:文中提供了详细的实例代码和调试技巧,帮助读者更好地理解和实施该项目。此外,还分享了一些实用的经验教训,有助于避免常见的错误和陷阱。
拨叉831003加工工艺及钻φ22花键底孔夹具设计.rar
scratch少儿编程逻辑思维游戏源码-像素冒险.zip
内容概要:本文深入探讨了单相和三相交流调压技术,详细介绍了这两种技术的工作原理、应用场景以及波形变化规律。首先,文章解释了单相交流调压的基本概念,即通过对单一相位的交流电进行触发角调整来实现电压调节。接着,重点讨论了三相交流调压的特点,特别是在带有中性线的情况下,它能提供更稳定的参考点并支持复杂的工业应用。此外,文中还涉及了桥式半控整流电路的仿真实验,展示了不同触发角和负载条件下的波形变化情况。最后,文章展望了未来交流调压技术面临的挑战和发展机遇。 适合人群:从事电力电子相关行业的技术人员、研究人员及高校师生。 使用场景及目标:帮助读者深入了解单相和三相交流调压技术的具体实现方式,掌握波形变化规律,提升实际操作能力。 其他说明:文章结合理论与实践,既包含了基础知识介绍又涵盖了最新的研究成果和技术趋势。
实训商业源码-恐龙快跑游戏小程序 4.1.3-毕业设计.zip
scratch少儿编程逻辑思维游戏源码-闲暇礼物制作.zip
实训商业源码- 深蓝健身房瑜伽馆行业小程序V4.15.0 前端+后端-毕业设计.zip
基于python+YOLO的火灾视频监测算法+源码+项目文档,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用,详情见md文档 基于python+YOLO的火灾视频监测算法+源码+项目文档,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用,详情见md文档~ 基于python+YOLO的火灾视频监测算法+源码+项目文档,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用,详情见md文档 基于python+YOLO的火灾视频监测算法+源码+项目文档,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用,详情见md文档 基于python+YOLO的火灾视频监测算法+源码+项目文档,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用,详情见md文档 基于python+YOLO的火灾视频监测算法+源码+项目文档,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用,详情见md文档
实训商业源码-二次元带音乐404页面源码-毕业设计.zip
【数字经济】大数据标注系统设计方案
scratch少儿编程逻辑思维游戏源码-粘粘世界物理.zip
少儿编程scratch项目源代码文件案例素材-自然.zip
scratch少儿编程逻辑思维游戏源码-物理引擎 V2.2.zip
ssm社区物业信息管理系统小程序(文档+源码)_kaic
反极域和远程机惨的好工具