JS文件:
//表单数据加载示例: Ext.onReady(function(){ Ext.QuickTips.init(); var productForm=Ext.create('Ext.form.Panel',{ title:'表单表单加载示例', width:300, frame:true, fieldDefaults:{ labelSeparator:':', labelWidth:80, width:200 }, renderTo:Ext.getBody(), items:[{ fieldLabel:'产品名称', xtype:'textfield', name:'productName', value:'U盘'//同步加载数据 },{ fieldLabel:'金额', xtype:'numberfield', name:'price', value:100//同步加载数据 },{ fieldLabel:'生产日期', xtype:'datefield', format:'Y年m月d日',//显示日期的格式 name:'date', value:new Date()//同步加载数据 },{ xtype:'hidden', name:'productId', value:'001'//产品id },{ fieldLabel:'产品简介', name:'introduction', xtype:'textarea' }], buttons:[{ text:'加载简介', handler:loadIntroduction }] }); //表单加载数据的回调函数 function loadIntroduction(){ var params=productForm.getForm().getValues(); productForm.getForm().load({ params:params,//传递参数 url:'011_1productServer.jsp',//请求的url地址 method:'GET',//请求方式 success:function(form,action){//加载成功的处理函数 Ext.Msg.alert('提示','产品简介加载成功'); }, failure:function(form,action){//加载失败的处理函数 Ext.Msg.alert('提示','产品简介加载失败<br>失败原因:'); } }); } });
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'JS1.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- extjs的样式文件 --> <link rel="stylesheet" type="text/css" href="js/extjs/resources/css/ext-all.css"> <!-- extjs的核心文件 --> <script type="text/javascript" charset="utf-8" src="js/extjs/ext-all-debug.js"></script> <!-- 国际化文件 --> <script type="text/javascript" charset="utf-8" src="js/extjs/ext-lang-zh_CN.js"></script> <script type="text/javascript" charset="utf-8" src="base/011_form_dateandother.js"></script> </head> <body> </body> </html>