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 配置 

<?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 这个回调函数执行相应的处理.关闭当前页面. 

你可能感兴趣的:(javaweb,dwz)