`

DWZ整合struts2笔记

阅读更多
找了好几个ajax框架,原来使用dorado,太难维护了.事件一大堆,插件经常崩溃.
另外一堆难以解决的问题.很不适合做互联网项目.
为了用户体验,重新寻找ajax框架.
jqueryui.com
以及http://www.ligerui.com/
http://demo.dwzjs.com/
都还不错.
弄来弄去 最终选择了dwzjs,虽然dwz还有很多问题.感觉对java开发还比较友好.
而且有个实例作为参考.先将就着用把.
下面记录下struts2整合dwz.一个痛苦的过程.
A.struts2配置略去.

B.spring action配置
==================nirana-context.xml==========================
  <!-- 商品manager  beans标签 配置了自动注入,default-autowire="autodetect" 所以同名的bean 会自动注入 -->
    <bean id="goodsManagerAction" class="com.bstek.scm.action.dwz.GoodsManagerAction">
         <property name="prdManager">
      <ref bean="prdManager"/>
     </property>
    </bean>

C.struts 配置
===================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>

    <!--  <include file="struts-default.xml"/> -->
	<!-- 是否显示详细错误信息 -->
	<constant name="struts.devMode" value="true" />
	<!-- 国际化资源文件名称 -->
	<constant name="struts.custom.i18n.resources" value="i18n" />
	<!-- 是否自动加载国际化资源文件  -->
	<constant name="struts.i18n.reload" value="false" />
	<!-- convention类重新加载 -->
	<constant name="struts.convention.classes.reload" value="false" />
	<!-- 浏览器是否缓存静态内容 -->
	<constant name="struts.serve.static.browserCache" value="false" />
	<!-- 配置使用Spring管理Action -->
	<constant name="struts.objectFactory" value="spring" />
	<!-- 上传文件大小限制设置 -->
	<constant name="struts.multipart.maxSize" value="-1" />

	<!-- 主题 -->
	<constant name="struts.ui.theme" value="simple" />
	<!-- 编码 -->
	<constant name="struts.i18n.encoding" value="UTF-8" />
	<!-- 后缀 -->
	<constant name="struts.action.extension" value="action" />

	<!-- 结果资源的路径 -->
	<constant name="struts.convention.result.path" value="/web/" />
	<!-- URL资源分隔符 -->
	<constant name="struts.convention.action.name.separator" value="_" />
	<!-- spring 缓存机制 -->
	<constant name="struts.objectFactory.spring.useClassCache" value="false"/>
	
	<package name="basePackage" extends="struts-default">
		<interceptors>
			<interceptor-stack name="baseStack">
                <interceptor-ref name="exception" />
                <interceptor-ref name="alias" />
                <interceptor-ref name="servletConfig" />
                <interceptor-ref name="i18n" />
                <interceptor-ref name="prepare" />
                <interceptor-ref name="chain" />
                <interceptor-ref name="debugging" />
                <interceptor-ref name="scopedModelDriven" />
                <interceptor-ref name="modelDriven" />
                <interceptor-ref name="fileUpload" />
                <interceptor-ref name="checkbox" />
                <interceptor-ref name="multiselect" />
                <interceptor-ref name="staticParams" />
                <interceptor-ref name="actionMappingParams" />
                <interceptor-ref name="params">
					<param name="excludeParams">dojo\..*,^struts\..*</param>
                </interceptor-ref>
                <interceptor-ref name="conversionError"/>
                <!-- 配置方法级别的校验 -->
                <interceptor-ref name="validation">
                    <param name="excludeMethods">input,back,cancel,browse</param>
                    <param name="validateAnnotatedMethodOnly">true</param>
                </interceptor-ref>
                <interceptor-ref name="workflow">
                    <param name="excludeMethods">input,back,cancel,browse</param>
                </interceptor-ref>
            </interceptor-stack>
		</interceptors>

		<!-- 配置默认拦截器栈 -->
		<default-interceptor-ref name="baseStack" />

		<!-- 未到找Action指向页面 -->
		<default-action-ref name="errorPage" />

        <global-results>
	      <result name="ajaxDone">/dwztest/ajaxDone.jsp</result>
	    </global-results>
	    
		<action name="errorPage">
			<result type="redirect">/html/error_page_404.html</result>
		</action>
		
		
	</package>
	
	<!-- 涅磐 action -->
	<package name="nirvana" extends="basePackage" namespace="/nirvana">
        <action name="nirvanaAction" class="nirvanaAction">
		    <result name="userlogin">/nirvana/nirvana_userlogin.jsp</result>
		    <result name="test">/nirvana/nirvana_test.ftl</result>
		    <result name="list">/nirvana/nirvana_list.jsp</result>
		    <result name="addGoods">/nirvana/addGoods.jsp</result>
		</action>
    </package>
    
    <!-- json 测试action -->
    <package name="json" extends="struts-default,json-default" namespace="/json">  
            <action name="jsonAction" class="jsonAction">  
                <interceptor-ref name="params"/>  
                <result type="json">
                   <!--   <param name="root">jsonResult</param> -->
                      <param name="includeProperties">
                       goodsList\[\d+\]\.goods_uid,goodsList\[\d+\]\.goods_name
					</param> 
                </result>  
            </action>  
            
            <action name="goodAddAction" class="jsonAction">
	               <result type="json"></result>
            </action>
    </package>  
    
    
	
	
	<package name="dwz" extends="basePackage" namespace="/dwz">
        <action name="goodsManagerAction" class="goodsManagerAction">
            <result name="list">/dwztest/goods_manager_list.jsp</result>
            <result name="input">/dwztest/goods_manager_input.jsp</result>
            <result name="addOk" type="redirectAction">goodsManagerList</result>
        </action>
        
        <action name="goodsManagerList" 
			class="goodsManagerAction" method="list">
			<result name="list">/dwztest/goods_manager_list.jsp</result>
		</action>
    </package>
    
</struts>



D.提交后相应页面,其实就是返回回调函数的一些数据,用于执行回调
==================ajaxDone.jsp===========================
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
{
"statusCode":"${statusCode}",
"message":"${tipsMessage}",
"forwardUrl":"${forwardUrl}",
"navTabId":"${param.navTabId}",
"callbackType":"${param.callbackType}"
}

E.主页
===================dwz.jsp=================
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>简单实用国产jQuery UI框架 - DWZ富客户端框架(J-UI.com)</title>

<link href="/SCM/ui/dwz/themes/default/style.css" rel="stylesheet" type="text/css" />
<link href="/SCM/ui/dwz/themes/css/core.css" rel="stylesheet" type="text/css" />
<link href="/SCM/ui/dwz/uploadify/css/uploadify.css" rel="stylesheet" type="text/css" />
<!--[if IE]>
<link href="/SCM/ui/dwz/themes/css/ieHack.css" rel="stylesheet" type="text/css" />
<![endif]-->

<script src="/SCM/ui/dwz/js/speedup.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/jquery-1.4.4.js" type="text/javascript"></script>

<script src="/SCM/ui/dwz/js/jquery.cookie.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/jquery.validate.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/jquery.bgiframe.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/xheditor/xheditor-1.1.8-zh-cn.min.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/uploadify/scripts/swfobject.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/uploadify/scripts/jquery.uploadify.v2.1.0.js" type="text/javascript"></script>

<script src="/SCM/ui/dwz/js/dwz.core.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.util.date.js" type="text/javascript"></script>

<script src="/SCM/ui/dwz/js/dwz.validate.method.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.regional.zh.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.barDrag.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.drag.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.tree.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.accordion.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.ui.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.theme.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.switchEnv.js" type="text/javascript"></script>

<script src="/SCM/ui/dwz/js/dwz.alertMsg.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.contextmenu.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.navTab.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.tab.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.resize.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.dialog.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.dialogDrag.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.cssTable.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.stable.js" type="text/javascript"></script>

<script src="/SCM/ui/dwz/js/dwz.taskBar.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.ajax.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.pagination.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.database.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.datepicker.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.effects.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.panel.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.checkbox.js" type="text/javascript"></script>
<script src="/SCM/ui/dwz/js/dwz.history.js" type="text/javascript"></script>

<script src="/SCM/ui/dwz/js/dwz.combox.js" type="text/javascript"></script>

<!--
<script src="bin/dwz.min.js" type="text/javascript"></script>
-->
<script src="/SCM/ui/dwz/js/dwz.regional.zh.js" type="text/javascript"></script>

<script type="text/javascript">
$(function(){
	DWZ.init("/SCM/ui/dwz/dwz.frag.xml", {
		//loginUrl:"login_dialog.html", loginTitle:"登录",	// 弹出登录对话框
		loginUrl:"login.jsp",	// 跳到登录页面
		statusCode:{ok:200, error:300, timeout:301}, //【可选】
		pageInfo:{pageNum:"pageNum", numPerPage:"numPerPage", orderField:"orderField", orderDirection:"orderDirection"}, //【可选】
		debug:false,	// 调试模式 【true|false】
		callback:function(){
			initEnv();
			$("#themeList").theme({themeBase:"/SCM/ui/dwz/themes"});
		}
	});
});
</script>
</head>

<body scroll="no">
	<div id="layout">
		<div id="header">
			<div class="headerNav">

				<a class="logo" href="http://j-ui.com">标志</a>
				<ul class="nav">
					<li id="switchEnvBox"><a href="javascript:">(<span>北京</span>)切换城市</a>
						<ul>
							<li><a href="sidebar_1.html">北京</a></li>
							<li><a href="sidebar_2.html">上海</a></li>

							<li><a href="sidebar_2.html">南京</a></li>
							<li><a href="sidebar_2.html">深圳</a></li>
							<li><a href="sidebar_2.html">广州</a></li>
							<li><a href="sidebar_2.html">天津</a></li>
							<li><a href="sidebar_2.html">杭州</a></li>
						</ul>

					</li>
					<li><a href="changepwd.html" target="dialog" width="600">设置</a></li>
					<li><a href="http://www.cnblogs.com/dwzjs" target="_blank">博客</a></li>
					<li><a href="http://weibo.com/dwzui" target="_blank">微博</a></li>
					<li><a href="http://bbs.dwzjs.com" target="_blank">论坛</a></li>
					<li><a href="login.html">退出</a></li>

				</ul>
				<ul class="themeList" id="themeList">
					<li theme="default"><div class="selected">蓝色</div></li>
					<li theme="green"><div>绿色</div></li>
					<!--<li theme="red"><div>红色</div></li>-->
					<li theme="purple"><div>紫色</div></li>
					<li theme="silver"><div>银色</div></li>

					<li theme="azure"><div>天蓝</div></li>
				</ul>
			</div>

			<!-- navMenu -->
			
		</div>

		<div id="leftside">
			<div id="sidebar_s">

				<div class="collapse">
					<div class="toggleCollapse"><div></div></div>
				</div>
			</div>
			<div id="sidebar">
				<div class="toggleCollapse"><h2>主菜单</h2><div>收缩</div></div>

				<div class="accordion" fillSpace="sidebar">

					<div class="accordionHeader">
						<h2><span>Folder</span>界面组件</h2>
					</div>
					<div class="accordionContent">
						<ul class="tree treeFolder">
							<li><a href="tabsPage.html" target="navTab">主框架面板</a>
								<ul>

									<li><a href="main.html" target="navTab" rel="main">我的主页</a></li>
									<li><a href="http://www.baidu.com" target="navTab" rel="page1">页面一(外部页面)</a></li>
									<li><a href="/SCM/nirvana/nirvanaAction!addGoods.action" target="navTab" rel="external" external="true">测试DWZ</a></li>
									<li><a href="/SCM/dwz/goodsManagerAction!list.action" target="navTab" rel="page100" >商品管理</a></li>
									
									
									<li><a href="/SCM/purchase/add_stock_order.jsp" target="navTab" rel="stock" external="true">采购订单</a></li>
									
									<li><a href="demo_page2.html" target="navTab" rel="external" external="true">iframe navTab页面</a></li>
									<li><a href="demo_page1.html" target="navTab" rel="page1" fresh="false">替换页面一</a></li>
									<li><a href="demo_page2.html" target="navTab" rel="page2">页面二</a></li>
									<li><a href="demo_page4.html" target="navTab" rel="page3" title="页面三(自定义标签名)">页面三</a></li>

									<li><a href="demo_page4.html" target="navTab" rel="page4" fresh="false">测试页面(fresh="false")</a></li>
									<li><a href="w_editor.html" target="navTab">表单提交会话超时</a></li>
									<li><a href="ajaxTimeout.html" target="navTab">navTab会话超时</a></li>
									<li><a href="ajaxTimeout.html" target="dialog">dialog会话超时</a></li>
									<li><a href="index_menu.html" target="_blank">横向导航条</a></li>
								</ul>

							</li>
							
							<li><a>常用组件</a>
								<ul>
									<li><a href="w_panel.html" target="navTab" rel="w_panel">面板</a></li>
									<li><a href="w_tabs.html" target="navTab" rel="w_tabs">选项卡面板</a></li>
									<li><a href="w_dialog.html" target="navTab" rel="w_dialog">弹出窗口</a></li>
									<li><a href="w_alert.html" target="navTab" rel="w_alert">提示窗口</a></li>

									<li><a href="w_list.html" target="navTab" rel="w_list">CSS表格容器</a></li>
									<li><a href="demo_page1.html" target="navTab" rel="w_table">表格容器</a></li>
									<li><a href="w_removeSelected.html" target="navTab" rel="w_table">表格数据库排序+批量删除</a></li>
									<li><a href="w_tree.html" target="navTab" rel="w_tree">树形菜单</a></li>
									<li><a href="w_accordion.html" target="navTab" rel="w_accordion">滑动菜单</a></li>
									<li><a href="w_editor.html" target="navTab" rel="w_editor">编辑器</a></li>

									<li><a href="w_datepicker.html" target="navTab" rel="w_datepicker">日期控件</a></li>
									<li><a href="db_widget.html" target="navTab" rel="w_datepicker">dwz.database.js</a></li>
								</ul>
							</li>
									
							<li><a>表单组件</a>
								<ul>
									<li><a href="db_masterEdit.html" target="navTab" rel="masterEdit">表单主从结构</a></li>

									<li><a href="w_validation.html" target="navTab" rel="w_validation">表单验证</a></li>
									<li><a href="w_button.html" target="navTab" rel="w_button">按钮</a></li>
									<li><a href="w_textInput.html" target="navTab" rel="w_textInput">文本框/文本域</a></li>
									<li><a href="w_combox.html" target="navTab" rel="w_combox">下拉菜单</a></li>
									<li><a href="w_checkbox.html" target="navTab" rel="w_checkbox">多选框/单选框</a></li>
									<li><a href="demo_upload.html" target="navTab" rel="demo_upload">iframeCallback表单提交</a></li>

									<li><a href="w_uploadify.html" target="navTab" rel="w_uploadify">uploadify多文件上传</a></li>
								</ul>
							</li>
							<li><a href="dwz.frag.xml" target="navTab" external="true">dwz.frag.xml</a></li>
						</ul>
					</div>
					<div class="accordionHeader">
						<h2><span>Folder</span>典型页面</h2>

					</div>
					<div class="accordionContent">
						<ul class="tree treeFolder treeCheck">
							<li><a href="demo_page1.html" target="navTab" rel="demo_page1">查询我的客户</a></li>
							<li><a href="demo_page1.html" target="navTab" rel="demo_page2">表单查询页面</a></li>
							<li><a href="demo_page4.html" target="navTab" rel="demo_page4">表单录入页面</a></li>
							<li><a href="demo_page5.html" target="navTab" rel="demo_page5">有文本输入的表单</a></li>

							<li><a href="javascript:;">有提示的表单输入页面</a>
								<ul>
									<li><a href="javascript:;">页面一</a></li>
									<li><a href="javascript:;">页面二</a></li>
								</ul>
							</li>
							<li><a href="javascript:;">选项卡和图形的页面</a>

								<ul>
									<li><a href="javascript:;">页面一</a></li>
									<li><a href="javascript:;">页面二</a></li>
								</ul>
							</li>
							<li><a href="javascript:;">选项卡和图形切换的页面</a></li>
							<li><a href="javascript:;">左右两个互动的页面</a></li>

							<li><a href="javascript:;">列表输入的页面</a></li>
							<li><a href="javascript:;">双层栏目列表的页面</a></li>
						</ul>
					</div>
					<div class="accordionHeader">
						<h2><span>Folder</span>流程演示</h2>
					</div>

					<div class="accordionContent">
						<ul class="tree">
							<li><a href="newPage1.html" target="dialog" rel="dlg_page">列表</a></li>
							<li><a href="newPage1.html" target="dialog" rel="dlg_page">列表</a></li>
							<li><a href="newPage1.html" target="dialog" rel="dlg_page2">列表</a></li>
							<li><a href="newPage1.html" target="dialog" rel="dlg_page2">列表</a></li>
							<li><a href="newPage1.html" target="dialog" rel="dlg_page2">列表</a></li>

						</ul>
					</div>
				</div>

			</div>
		</div>
		<div id="container">
			<div id="navTab" class="tabsPage">
				<div class="tabsPageHeader">

					<div class="tabsPageHeaderContent"><!-- 显示左右控制时添加 class="tabsPageHeaderMargin" -->
						<ul class="navTab-tab">
							<li tabid="main" class="main"><a href="javascript:;"><span><span class="home_icon">我的主页</span></span></a></li>
						</ul>
					</div>
					<div class="tabsLeft">left</div><!-- 禁用只需要添加一个样式 class="tabsLeft tabsLeftDisabled" -->
					<div class="tabsRight">right</div><!-- 禁用只需要添加一个样式 class="tabsRight tabsRightDisabled" -->

					<div class="tabsMore">more</div>
				</div>
				<ul class="tabsMoreList">
					<li><a href="javascript:;">我的主页</a></li>
				</ul>
				<div class="navTab-panel tabsPageContent">
					<div class="page">
						<div class="accountInfo">

							<div class="alertInfo">
								<h2><a href="doc/dwz-user-guide.pdf" target="_blank">DWZ框架使用手册(PDF)</a></h2>
								<a href="doc/dwz-user-guide.swf" target="_blank">DWZ框架演示视频</a>
							</div>
							<div class="right">
								<p><a href="doc/dwz-user-guide.zip" target="_blank" style="line-height:19px">DWZ框架使用手册(CHM)</a></p>
								<p><a href="doc/dwz-ajax-develop.swf" target="_blank" style="line-height:19px">DWZ框架Ajax开发视频教材</a></p>

							</div>
							<p><span>DWZ富客户端框架</span></p>
							<p>DWZ官方微博:<a href="http://weibo.com/dwzui" target="_blank">http://weibo.com/dwzui</a></p>
						</div>
						<div class="pageFormContent" layoutH="80" style="margin-right:230px">
							
							<p style="color:red">DWZ官方微博 <a href="http://weibo.com/dwzui" target="_blank">http://weibo.com/dwzui</a></p>

							<p style="color:red">DWZ官方微群 <a href="http://q.weibo.com/587328/invitation=11TGXSt-148c2" target="_blank">http://q.weibo.com/587328/invitation=11TGXSt-148c2</a></p>


						</div>
						
						<div style="width:230px;position: absolute;top:60px;right:0" layoutH="80">
							<iframe width="100%" height="430" class="share_self"  frameborder="0" scrolling="no" src="http://service.t.sina.com.cn/widget/WeiboShow.php?width=0&height=430&fansRow=1&ptype=1&speed=0&skin=1&isTitle=1&noborder=1&isWeibo=1&isFans=1&uid=1739071261&verifier=c683dfe7"></iframe>
						</div>
					</div>
					
				</div>
				
			</div>

		</div>

	</div>

	<div id="footer">Copyright &copy; 2010 <a href="demo_page2.html" target="dialog">DWZ研发组</a></div>


<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-16716654-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? ' https://ssl' : ' http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>

</body>
</html>


F.列表页
==================goods_manager_list.jsp===================
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@ include file="/dwztest/dwz_include.jsp"%>

<form id="pagerForm" action="loginList.action">
	<input type="hidden" name="pageInfo.currentPage" value="${pageInfo.currentPage}" />
	<input type="hidden" name="lookup" value="${lookup}" />
</form>

<div class="pageHeader">
	<form rel="pagerForm" method="post" action="/SCM/dwz/goodsManagerAction!list.action" onsubmit="return dwzSearch(this, '${targetType}');">
	<input type="hidden" name="pageInfo.pageSize" value="${pageInfo.pageSize}" />
	<div class="searchBar">
		<ul class="searchContent">	
		</ul>
		<div class="subBar">
			<div class="buttonActive"><div class="buttonContent"><button type="submit">查询</button></div></div>
		</div>
	</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
				<li><a class="add" href="/SCM/dwz/goodsManagerAction!add.action" target="navTab" rel="login"><span>新建</span></a></li>
				<li><a class="delete" href="/SCM/dwz/goodsManagerAction!del.action" target="removeSelected" title="确实要删除这些记录吗?"><span>批量删除</span></a></li>
		</ul>
	</div>
	<table class="table" width="100%" layoutH="138" targetType="${targetType}">
		<thead>
			<tr>
			
				<th width="22"><input type="checkbox" group="orderIndexs" class="checkboxCtrl"></th>
				<th>商品编号</th>
				<th>商品名称</th>
			</tr>
		</thead>				
		<tbody>
			<c:forEach var="item" items="${goodsList}" varStatus="s">
			<tr>
				    <td><input name="orderIndexs" value="${item.goods_uid}" type="checkbox"></td>
				    <td>${item.goods_code}</td>
				    <td>${item.goods_name}</td>
			</tr>
			</c:forEach>
		</tbody>
	</table>	
	<div class="panelBar">
		<div class="pages">
			<span>每页</span>
			<c:set var="pageSizeList" value="${fn:split('10|20|50|100', '|')}"/>  
			<select name="pageInfo.pageSize" onchange="dwzPageBreak({targetType:'${targetType}', numPerPage:this.value})">
				<c:forEach var="item" items="${pageSizeList}">
				<option value="${item}" ${item eq pageInfo.pageSize ? 'selected="selected"' : ''}>${item}</option>
				</c:forEach>
			</select>
			<span>条,共${pageInfo.totalRecords}条</span>
		</div>
		<div class="pagination" targetType="${targetType}" totalCount="${pageInfo.totalRecords}" numPerPage="${pageInfo.pageSize}" pageNumShown="${pageInfo.totalPage}" currentPage="${pageInfo.currentPage}"></div>
	</div>
</div>



G.添加页
==================goods_manager_input.jsp========================================
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@ include file="/dwztest/dwz_include.jsp"%>

<h2 class="contentTitle">商品编辑页面</h2>
<form action="/SCM/dwz/goodsManagerAction!save.action?navTabId=page100&callbackType=closeCurrent&ajax=1" method="post" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone)">
<div class="pageContent">
	<div class="pageFormContent" layoutH="97">
	   <dl>
	      <dt>类目id:</dt>
	      <dd><input type="text" name="goods.catagory_uid" class="textInput" value="${goods.catagory_uid}" /></dd>
	   </dl>
	   <dl>
	      <dt>商品编号:</dt>
	      <dd><input type="text" name="goods.goods_code" class="textInput" value="${goods.goods_code}" /></dd>
	   </dl>
	   <dl>
	      <dt>商品名称:</dt>
	      <dd><input type="text" name="goods.goods_name" class="textInput" value="${goods.goods_name}" /></dd>
	   </dl>
	    <dl>
	      <dt>采购价:</dt>
	      <dd><input type="text" name="goods.prime_price" class="textInput" value="${goods.prime_price}" /></dd>
	   </dl>
	    <dl>
	      <dt>销售价:</dt>
	      <dd><input type="text" name="goods.sale_price" class="textInput" value="${goods.sale_price}" /></dd>
	   </dl>
	    <dl>
	      <dt>是否多规格:</dt>
	      <dd><input type="text" name="goods.ismutil" class="textInput" value="${goods.ismutil}" /></dd>
	   </dl>
	   <dl>
	      <dt>状态:</dt>
	      <dd><input type="text" name="goods.status" class="textInput" value="${goods.status}" /></dd>
	   </dl>
		<div class="divider"></div>
	</div>
	<div class="formBar">
		<ul>
			<li><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
			<li><div class="button"><div class="buttonContent"><button class="close" type="button">关闭</button></div></div></li>
		</ul>
	</div>  
</div>
</form>


h.GoodsManagerAction
=====================GoodsManagerAction.java==========================
/**
 * 
 */
package com.bstek.scm.action.dwz;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.struts2.ServletActionContext;
import org.marmot.view.Page;

import com.bstek.scm.bo.prd.PrdManager;
import com.bstek.scm.common.exception.ManagerException;
import com.bstek.scm.common.tools.LogFactory;
import com.bstek.scm.pojo.prd.Goods;

/**
 * 商品管理action
 * @author fengbin
 * @createDate Aug 22, 2011 9:00:13 PM  
 */
public class GoodsManagerAction extends BaseAction {

	private static final long serialVersionUID = -876958304704173139L;
	private Goods goods;
	private GoodsManagerPageInfo pageInfo;
	private List<Goods> goodsList;
	
	//商品manager
	private PrdManager prdManager;
	
	/**
	 * 获取所有商品
	 * @return
	 */
	public String list(){
		
		try {
			int pageSize = 20;
			int pageIndex = 1;
			Map<String,Object> parameters = new HashMap<String,Object>();
			Page page =prdManager.getGoods(parameters, pageSize, pageIndex);
			goodsList = page.getList();
			
			pageInfo = new GoodsManagerPageInfo();
			pageInfo.setCurrentPage(1);
			pageInfo.setTotalRecords(page.getTotalCount());
			
			
		} catch (ManagerException e) {
			LogFactory.errLog.error("保存采购入库单出错!",e);
		}
		
		return "list";	
	}
	
	/**
	 * 新建
	 * @param prdManager
	 */
	public String add(){
		
		goods=null;
		return "input";
		
	}
	
	/**
	 * 保存
	 * @param prdManager
	 */
	public String save(){
		
		try {
			prdManager.saveGoods(goods);
			 ServletActionContext.getResponse().setContentType("text/html");
		} catch (ManagerException e) {
			LogFactory.errLog.error("商品添加出错!",e);
		}
		
		return ajaxForwardSuccess("商品添加成功!");
		
	}
	
	
	
	public void setPrdManager(PrdManager prdManager) {
		this.prdManager = prdManager;
	}



	public void setGoods(Goods goods) {
		this.goods = goods;
	}
	public void setPageInfo(GoodsManagerPageInfo pageInfo) {
		this.pageInfo = pageInfo;
	}
	public void setGoodsList(List<Goods> goodsList) {
		this.goodsList = goodsList;
	}
	public Goods getGoods() {
		return goods;
	}
	public GoodsManagerPageInfo getPageInfo() {
		return pageInfo;
	}
	public List<Goods> getGoodsList() {
		return goodsList;
	}
	
	
	
	

}



g.BaseAction
==========================================================
package com.bstek.scm.action.dwz;
 
 import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.ActionSupport;
 
 public class BaseAction extends ActionSupport{
	 
	 
	private static final long serialVersionUID = -676538067021681709L;
   private String lookup;
   private String workflow;
//   private Object errorObject;
   protected static final String DOWNLOAD = "download";
   protected static final String AUTO = "auto";
   private ActionProxy proxy;
   private int statusCode = 200;
   private String tipsMessage;
   private String forwardUrl;
   private String ajax;
 
   public ActionProxy getProxy()
   {
     if (this.proxy == null)
       this.proxy = ActionContext.getContext().getActionInvocation().getProxy();
     return this.proxy;
   }
 
   public String getLookup() {
     return this.lookup;
   }
 
   public void setLookup(String lookup) {
     this.lookup = lookup;
   }
 
   public HttpServletRequest getRequest() {
     return ServletActionContext.getRequest();
   }
 
   public HttpServletResponse getResponse() {
     return ServletActionContext.getResponse();
   }
 
   public HttpSession getSession()
   {
     return ServletActionContext.getRequest().getSession(true);
   }
 
   public String getParameter(String name) {
     return getRequest().getParameter(name);
   }
 
//   public Object getErrorObject() {
//     return this.errorObject;
//   }
// 
//   public void setErrorObject(Object errorObject) {
//     this.errorObject = errorObject;
//   }
 
   protected Date getDateFromStr(String sendTime_str)
   {
     Date returnDate = null;
     DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
     if ((sendTime_str == null) || (sendTime_str.equals("")))
     {
       return null;
     }
     try
     {
       returnDate = df.parse(sendTime_str);
     }
     catch (Exception e)
     {
       returnDate = null;
     }
 
     return returnDate;
   }
 
  
   public String getWorkflow() {
     return this.workflow;
   }
 
   public void setWorkflow(String workflow) {
     this.workflow = workflow;
   }
 
   protected String returnCommand(){
     return returnCommand(null); 
   }
 
   protected String returnCommand(String message) {
       if ((((this.ajax == null) || (!(this.ajax.trim().equals("1"))))) && (message == null))
         return "success";
       if (message == null) {
    	   //ajaxForwardSuccess(I18NUtil.getString("鎿嶄綔鎴愬姛"))
         return ajaxForwardSuccess("成功!");
       }
       return ajaxForwardError(message);
   }
 
   public void setAjax(String ajax)
   {
     this.ajax = ajax;
   }
 
   public int getStatusCode() {
     return this.statusCode;
   }
 
   public void setStatusCode(int statusCode) {
     this.statusCode = statusCode;
   }
 
   public String getTipsMessage() {
     return this.tipsMessage;
   }
 
   public void setTipsMessage(String tipsMessage) {
     this.tipsMessage = tipsMessage;
   }
 
   public String getForwardUrl() {
     return this.forwardUrl;
   }
 
   public void setForwardUrl(String forwardUrl) {
     this.forwardUrl = forwardUrl; }
 
   public String getTargetType() {
     if ((this.lookup != null) && (this.lookup.length() > 0)) {
       return "dialog";
     }
     return "navTab";
   }
 
   private String ajaxForward(int statusCode, String message) {
     this.statusCode = statusCode;
     this.tipsMessage = message;
     return "ajaxDone"; 
   }
 
   /**
    * ajax 提交后跳转
    * @param message
    * @return
    */
   protected String ajaxForwardSuccess(String message) {
     return ajaxForward(200, message); 
   }
 
   /**
    * ajax 提交失败后跳转
    * @param message
    * @return
    */
   protected String ajaxForwardError(String message) {
     return ajaxForward(300, message);
   }
 }





原理:
goods_manager_input.jsp页面中
<form action="/SCM/dwz/goodsManagerAction!save.action?navTabId=page100&callbackType=closeCurrent&ajax=1" method="post" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone)">

提交后跳转到ajaxDone.jsp 页面
这个页面就是回调函数,需要用到的数据.
然后通过 navTabAjaxDone 这个回调函数执行相应的处理.关闭当前页面.






分享到:
评论
8 楼 zhangchixtacbn 2015-07-09  
[img][/img]  
7 楼 wenlongsust 2013-05-07  
如何整合struts的后台校验功能呢?
前台校验和后台校验结合,这样的校验逻辑才比较完善
6 楼 lxShawn 2012-05-25  
你好,请问下,在分页过程中,用到一个GoodsManagerPageInfo的类,不知道这个类应该怎么定义呢?需要写些什么?
5 楼 zhaoqiu815 2012-04-26  
非常感谢!
4 楼 huzonghua 2011-11-30  
dwz能不能和SpringMVC整合啊,缺少和SpringMVC整合的例子啊,楼主要是能提供就万分感谢了!
3 楼 fengbin2005 2011-10-19  
已经是源码级了.
2 楼 南通ori 2011-10-19  
如果楼主能上传源码供大家学习研究就更好了
1 楼 logoc 2011-09-20  
写的非常好,学习中

相关推荐

    dwz.rar_dwz_dwz struts

    标题中的“dwz.rar_dwz_dwz struts”暗示了这是一个与DWZ(可能是Dynamic Web Zone的缩写)和Struts框架相关的压缩包。描述提到的“dwz+struts+仿habernate”可能意味着这个项目或教程是将DWZ、Struts以及一个模仿...

    dwz+struts 框架

    2. **分页显示**:DWZ框架内置了分页组件,只需要配置相应的参数,就可以实现前端页面的动态分页。在Struts后端,通过计算总记录数和每页显示数量,生成分页信息。 3. **框架搭建**:搭建DWZ+Struts项目,首先需要...

    DWZ+struts2+spring3.2+mybatis3

    【DWZ+Struts2+Spring3.2+MyBatis3】是一个常见的Java Web开发技术栈,结合了几个强大的框架来构建高效、稳定的Web应用。这个技术组合提供了模型-视图-控制器(MVC)架构,使得开发过程更加灵活和模块化。 DWZ...

    DWZ的demo工程(后台java实现,使用struts2)

    综上所述,这个"DWZ的demo工程(后台java实现,使用struts2)"涵盖了前端与后端的整合、数据库操作、CRUD业务逻辑以及分页功能的实现,为开发者提供了一个实践DWZ和Struts2结合的实例。通过学习和分析这个DEMO,...

    WABACUS整合Struts2、DWZ的项目源码

    基于WABACUS3.5+Struts2.3.8+DWZ1.4.4程序框架 修改简单改造了WABACUS3.5:实现了在Wabacus.report.config文件中设置报表文件配置XML和报表资源XML文件时文件路径和文件名称都可以使用通配符的功能,以方便以后将...

    dw与struts2的实例

    在"dw与struts2的实例"中,我们将探讨如何将DWZ UI框架与Struts2框架结合使用,创建一个完整的Web应用。首先,我们需要在项目中集成Struts2框架,这通常包括添加Struts2的相关依赖到项目的类路径,配置web.xml文件以...

    springmvc+mybatis+dwz整合

    通过`SpringMVC`、`MyBatis`和`DWZ`的整合,我们可以构建出一个高效的、具有良好用户体验的Web应用程序。这种架构模式广泛应用于企业级项目,因为它既提供了强大的后端逻辑处理能力,又确保了前端的交互性和美观性。...

    DWZ+ThinkPHP+kindeditor整合,及DWZ官方整合部分小BUG修复

    2、将kindeditor的上传功能及文件浏览功能整合到Thinkphp中,杜绝一些安全隐患。 3、原来 DWZ官方 整合的只有文章系统,没有文章分类,我将原来的文章的数据库字段做了一些修改,增加了无限级分类。 4、修复了一些...

    dwz,ztree整合,操作都在头部

    当我们说“dwz,ztree整合,操作都在头部”时,这意味着在DWZ框架的基础上,将ZTree的节点操作按钮集成到了页面的头部。这样做的好处是统一操作位置,提高用户操作的便捷性和一致性。下面我们将详细解释如何实现这一...

    think_DWZ整合

    "think_DWZ整合"指的是将ThinkPHP框架与DWZ(Discuz! Web Zone)前端框架结合使用,以实现高效、便捷的Web应用开发。在PHP编程领域,这样的整合能够充分利用ThinkPHP的强大后端处理能力和DWZ的精美前端界面设计,为...

    SpringMVC+Mybatis+DWZ整合例子(参考)

    1:SpringMVC+Mybatis+DWZ+Orcale整合 2:Oracle数据库账户Scott 密码123 自己根据实际情况修改 3:表在数据库里 4:只有”我的测试“一个可用,其余没做,错误页处理不完全,我注释了! 5:默认有登陆页面,账号密码...

    DWZ框架整合Java三大框架(购物系统Shop)

    在整合中,Struts2的动作类会调用Spring管理的服务,执行相应的业务逻辑,然后将结果通过视图展示给用户。此外,Struts2还提供了丰富的拦截器,可以进行权限验证、日志记录等功能。 4. **DWZ框架** DWZ(Design ...

    dwz框架实现拦截器 session超时跳转登陆页面

    dwz框架实现拦截器 session超时跳转登陆页面 DWZ框架 struts2拦截器 session超时

    基于DWZ富客户端框架的ssh2的项目 dwz4j

    【标题】"基于DWZ富客户端框架的ssh2的项目 dwz4j"是一个整合了SSH2(Spring、Struts2、Hibernate)三大框架与DWZ富客户端框架的Web应用程序项目。DWZ富客户端框架(DWZ UI Framework)是专为开发人员提供的一种轻量...

    hibernate3+spring2.5+struts2+dwz +项目模版生成工具

    这个“hibernate3+spring2.5+struts2+dwz +项目模版生成工具”是一个综合性的开发资源,帮助开发者快速构建基于SSH的Web应用,并且包含了一套模版生成工具,以提高开发效率。 1. **Spring框架**:Spring是Java企业...

    dwz+SpringMVC+mybatis

    【标题】"dwz+SpringMVC+mybatis"是一个基于DWZ(Dynamic Web Project)前端框架、SpringMVC后端控制器以及MyBatis持久层框架整合的Web应用开发架构。这种组合通常用于构建高效、灵活的企业级应用程序,提供从前端...

    基于DWZ富客户端框架的ssh2的项目lib包

    标题中的“基于DWZ富客户端框架的ssh2的项目lib包”表明这是一个使用DWZ(Dynamic Web Zone)富客户端框架,并结合SSH2(Struts2、Spring、Hibernate2)技术的开发项目。DWZ框架是一种JavaScript和Ajax技术的前端...

    SSH+dwz项目dwz4j的jar包

    综上所述,SSH+dwz项目是一个集成了Spring、Struts2和Hibernate的后端框架,配合dwz4j提供的前端UI组件,可以高效地开发出功能丰富、用户体验优良的Web应用。这47个jar包构成了项目的运行基础,包含了所有必要的库和...

    dwz完美整合ztree,kindeditor,My97DatePicker

    这份DWZ代码是我个人一直使用的,DWZ对各版本IE的兼容性是比较好的,我的代码在IE6下也基本能正常使用,这是一直舍不得换其它框架的主要原因。 压缩包是完整的jfinal+dwz的测试性小代码,直接导入myeclipse,运行...

    dwz整合kindeditor

    3分不贵的,这个问题解决的也不容易,今天突然来啦感觉,另外说下上次的dwz+ztree 是可以使用的,前几天看啦下评论发现有人说用不了,呵呵 可能 你有地方还木配置好, 具体的项目代码我就不贴了,不方便~~ 主要的我...

Global site tag (gtag.js) - Google Analytics