`
dujunxiaochuan
  • 浏览: 34143 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

Smartclient+demo+实例

阅读更多

此文为转载

 

用实例见证smartclient的厉害吧。

  1. 先貼出來圖片炫炫!很閃吧。
  2. 建表語句:
  3. createtablesupplyItem(
  4. itemIDintprimarykeyidentity(1,1),
  5. itemNamevarchar(300),
  6. unitCostdecimal(28,2),--55.23
  7. SKUvarchar(30),
  8. descriptionvarchar(5000),
  9. categoryvarchar(128),
  10. inStockvarchar(30),
  11. unitsvarchar(30),
  12. nextShipmentdatetime
  13. )
  14. --droptablesupplyCategory
  15. createtablesupplyCategory(
  16. categoryNamevarchar(128)primarykey,
  17. parentIDvarchar(255),
  18. )
  19. demoAppJS.jsp
  20. Jsp代碼:
  21. <!--------------------------------------------------------------------
  22. 整合人:舒婷*_*
  23. ---------------------------------------------------------------------->
  24. <HTML>
  25. <HEAD>
  26. <TITLE>SmartClientDemoApplication</TITLE>
  27. <metahttp-equiv="pragma"content="no-cache">
  28. <metahttp-equiv="cache-control"content="no-cache">
  29. <metahttp-equiv="expires"content="0">
  30. <metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">
  31. <metahttp-equiv="description"content="Thisismypage">
  32. <SCRIPT>varisomorphicDir="isomorphic/";</SCRIPT>
  33. <SCRIPTSRC=smartclient/modules/ISC_History.js></SCRIPT>
  34. <SCRIPTSRC=smartclient/modules/ISC_Core.js></SCRIPT>
  35. <SCRIPTSRC=smartclient/modules/ISC_Foundation.js></SCRIPT>
  36. <SCRIPTSRC=smartclient/modules/ISC_Containers.js></SCRIPT>
  37. <SCRIPTSRC=smartclient/modules/ISC_Grids.js></SCRIPT>
  38. <SCRIPTSRC=smartclient/modules/ISC_Forms.js></SCRIPT>
  39. <SCRIPTSRC=smartclient/modules/ISC_DataBinding.js></SCRIPT>
  40. <SCRIPTSRC=smartclient/modules/load_skin.js></SCRIPT>
  41. </HEAD>
  42. <BODYCLASS="pageBackground"STYLE="overflow:hidden">
  43. <scriptsrc="demoAppJS.js"></script>
  44. </BODY>
  45. </HTML>
  46. demoAppJS.js
  47. isc.setAutoDraw(false);
  48. //<isomorphic:loadDSname="supplyItem"/>
  49. //<isomorphic:loadDSname="supplyCategory"/>
  50. isc.DataSource.create({
  51. ID:"supplyCategory",
  52. dataFormat:"xml",
  53. recordXPath:"//country",
  54. fields:[
  55. {name:"categoryName",primaryKey:true},
  56. {foreignKey:"supplyCategory.categoryName",//这一步不懂、??
  57. hidden:true,
  58. name:"parentID",
  59. required:true,
  60. rootValue:"root",//初始化加载parentID为root记录如果没有设置rootValue会出现死循环式的树
  61. type:"text"
  62. }
  63. ],
  64. operationBindings:[
  65. {
  66. operationType:"fetch",
  67. dataURL:"demoApp/findTreeAll.action"
  68. }
  69. ]
  70. });
  71. isc.DataSource.create({
  72. ID:"supplyItem",
  73. dataFormat:"xml",//数据格式xml格式
  74. recordXPath:"//country",//--<country></country>
  75. fields:[
  76. //{name:"itemId",primaryKey:true},//countryCode設置為主鍵
  77. {name:"itemName",title:"itemName"},
  78. {name:"unitCost",title:"unitCost"},
  79. {name:"SKU",title:"SKU"},
  80. {name:"description",title:"description"},
  81. {name:"category",title:"category"},
  82. {name:"inStock",title:"inStock"},
  83. {name:"nextShipment",title:"nextShipment"}
  84. ],
  85. operationBindings:[
  86. {operationType:"fetch",
  87. dataURL:"demoApp/findAll.action"
  88. },
  89. {operationType:"add"
  90. //dataURL:"country/insertInfo.action"
  91. },
  92. {operationType:"update"
  93. //dataURL:"country/updateInfo.action"
  94. },
  95. {operationType:"remove"
  96. //dataURL:"country/deleteInfo.action"
  97. }
  98. ]
  99. });
  100. isc.Page.setAppImgDir(isc.Page.getIsomorphicDocsDir()+"exampleImages/");//设置img文件路径
  101. isc.TreeGrid.create({
  102. ID:"categoryTree",
  103. dataSource:"supplyCategory",
  104. nodeClick:"findForm.findItems(node.categoryName)",
  105. showHeader:false,
  106. leaveScrollbarGap:false,
  107. animateFolders:true,
  108. canAcceptDroppedRecords:true,
  109. canReparentNodes:false,
  110. selectionType:"single",
  111. animateRowsMaxTime:750
  112. });
  113. isc.HTMLPane.create({
  114. ID:"helpCanvas",
  115. contentsURL:"demoApp_helpText.html",
  116. overflow:"auto",
  117. styleName:"defaultBorder",
  118. padding:10
  119. });
  120. isc.IButton.create({
  121. ID:"findButton",
  122. title:"Find",
  123. left:25,
  124. top:16,
  125. width:80,
  126. click:"findForm.findItems()",
  127. icon:"demoApp/icon_find.png",
  128. iconWidth:24
  129. });
  130. isc.SearchForm.create({
  131. ID:"findForm",
  132. dataSource:supplyItem,
  133. left:130,
  134. top:10,
  135. cellPadding:4,
  136. numCols:6,
  137. fields:[
  138. {name:"SKU"},
  139. {name:"itemName",editorType:"comboBox",optionDataSource:"supplyItem",
  140. pickListWidth:250},
  141. {name:"findInCategory",editorType:"checkbox",
  142. title:"Usecategory",defaultValue:true,shouldSaveValue:false}
  143. ],
  144. //Functiontoactuallyfinditems
  145. findItems:function(categoryName){
  146. varfindValues;
  147. if(this.getValue('findInCategory')&&categoryTree.selection.anySelected()){
  148. //usetreecategoryandformvalues
  149. if(categoryName==null)categoryName=categoryTree.getSelectedRecord().categoryName;
  150. findValues={category:categoryName};
  151. isc.addProperties(findValues,this.getValues());
  152. }elseif(categoryName==null){
  153. //useformvaluesonly
  154. findValues=this.getValues();
  155. }else{
  156. //usetreecategoryonly
  157. findValues={category:categoryName};
  158. }
  159. itemList.filterData(findValues);
  160. itemDetailTabs.clearDetails();
  161. }
  162. });
  163. isc.ListGrid.create({
  164. ID:"itemList",
  165. dataSource:supplyItem,
  166. useAllDataSourceFields:true,
  167. fields:[
  168. {name:"itemName",title:"Name",showHover:true},
  169. {name:"unitCost",
  170. formatCellValue:"returnisc.Format.toCurrencyString(parseFloat(value))",
  171. editorType:"spinner",editorProperties:{step:0.01}},
  172. {name:"SKU",canEdit:false},
  173. {name:"description",showHover:true},
  174. {name:"category",canEdit:false},
  175. {name:"inStock",width:55,align:"center",
  176. formatCellValue:function(value,record,field,rowNum,colNum){
  177. if(value)returnisc.Canvas.imgHTML("demoApp/checked.png",13,13);
  178. elsereturnisc.Canvas.imgHTML("demoApp/unchecked.png",13,13)
  179. }},
  180. {name:"nextShipment",showIf:"false"}
  181. ],
  182. recordClick:"this.updateDetails()",
  183. canEdit:true,
  184. modalEditing:true,
  185. cellChanged:"this.updateDetails()",
  186. alternateRecordStyles:true,
  187. canDragRecordsOut:true,
  188. hoverWidth:200,
  189. hoverHeight:20,
  190. selectionType:"single",
  191. cellContextClick:"returnitemListMenu.showContextMenu()",
  192. updateDetails:function(){
  193. varrecord=this.getSelectedRecord();
  194. if(record==null)returnitemDetailTabs.clearDetails();
  195. if(itemDetailTabs.getSelectedTabNumber()==0){itemViewer.setData(record)
  196. }else{
  197. itemDetailTabs.updateTab("editTab",editForm);
  198. editForm.editRecord(record);
  199. }
  200. }
  201. });
  202. isc.Menu.create({
  203. ID:"itemListMenu",
  204. cellHeight:22,
  205. data:[
  206. {title:"AddNewItem",
  207. icon:"demoApp/icon_add.png",
  208. click:function(){
  209. itemList.selection.deselectAll();
  210. itemDetailTabs.selectTab(1);
  211. itemList.updateDetails();
  212. }
  213. },
  214. {isSeparator:true},
  215. {title:"ShowDetails",
  216. icon:"demoApp/icon_view.png",
  217. click:"itemDetailTabs.selectTab(0);itemList.updateDetails()"},
  218. {title:"EditItem",
  219. icon:"demoApp/icon_edit.png",
  220. click:"itemDetailTabs.selectTab(1);itemList.updateDetails()"},
  221. {title:"DeleteItem",
  222. icon:"demoApp/icon_delete.png",
  223. click:"itemList.removeSelectedData();itemDetailTabs.clearDetails()"}
  224. ]
  225. });
  226. isc.DetailViewer.create({
  227. ID:"itemViewer",
  228. dataSource:supplyItem,
  229. width:"100%",
  230. margin:"25",
  231. emptyMessage:"Selectanitemtoviewitsdetails"
  232. });
  233. isc.DynamicForm.create({
  234. ID:"editForm",
  235. dataSource:supplyItem,
  236. useAllDataSourceFields:true,
  237. fields:[
  238. {name:"SKU"},
  239. {name:"description",editorType:"textArea",rowSpan:3,width:200},
  240. {name:"category",editorType:"pickTree",dataSource:supplyCategory,//无法显示editform
  241. emptyMenuMessage:"NoSubCategories",canSelectParentItems:true},
  242. {name:"unitCost",editorType:"spinner",step:0.01},
  243. {name:"inStock"},
  244. {name:"nextShipment",useTextField:true,editorType:"date"},
  245. {name:"savebtn",editorType:"button",align:"center",
  246. width:100,colSpan:4,title:"SaveItem",click:"editForm.saveData()"}
  247. ],
  248. width:650,
  249. numCols:4,
  250. colWidths:[100,200,100,200],
  251. margin:25,
  252. cellPadding:5,
  253. autoFocus:false
  254. });
  255. isc.Label.create({
  256. ID:"editorMessage",
  257. autoDraw:false,
  258. width:"100%",
  259. height:"100%",
  260. align:"center",
  261. contents:"Selectarecordtoedit,oracategorytoinsertanewrecordinto"
  262. });
  263. isc.TabSet.create({
  264. ID:"itemDetailTabs",
  265. tabs:[
  266. {title:"View",pane:itemViewer,ID:"viewTab",width:70,icon:"demoApp/icon_view.png"},
  267. {title:"Edit",pane:editForm,ID:"editTab",width:70,icon:"demoApp/icon_edit.png"}
  268. ],
  269. tabSelected:"itemList.updateDetails()",
  270. clearDetails:function(){
  271. varselectedTab=this.getSelectedTabNumber();
  272. if(selectedTab==0){
  273. itemViewer.setData();
  274. }elseif(selectedTab==1){
  275. if(categoryTree.getSelectedRecord()!=null){
  276. this.updateTab("editTab",editForm);
  277. editForm.editNewRecord({category:categoryTree.getSelectedRecord().categoryName});
  278. }else{
  279. this.updateTab("editTab",editorMessage);
  280. }
  281. }
  282. }
  283. });
  284. //Defineapplicationlayout
  285. //---------------------------------------------------------------------
  286. isc.HLayout.create({
  287. ID:"pageLayout",
  288. width:"100%",
  289. height:"100%",
  290. layoutMargin:20,
  291. members:[
  292. isc.SectionStack.create({
  293. ID:"leftSideLayout",
  294. width:280,
  295. showResizeBar:true,
  296. visibilityMode:"multiple",
  297. animateSections:true,
  298. sections:[
  299. {title:"OfficeSupplyCategories",autoShow:true,items:[categoryTree]},
  300. {title:"Instructions",autoShow:true,items:[helpCanvas]}
  301. ]
  302. }),
  303. isc.SectionStack.create({
  304. ID:"rightSideLayout",
  305. visibilityMode:"multiple",
  306. animateSections:true,
  307. sections:[
  308. {title:"FindItems",autoShow:true,items:[
  309. isc.Canvas.create({
  310. ID:"findPane",
  311. height:60,
  312. overflow:"auto",
  313. styleName:"defaultBorder",
  314. children:[findForm,findButton]
  315. })
  316. ]},
  317. {title:"OfficeSupplyItems",autoShow:true,items:[itemList]},
  318. {title:"ItemDetails",autoShow:true,items:[itemDetailTabs]}
  319. ]
  320. })
  321. ]
  322. });
  323. isc.Page.setEvent("load","pageLayout.draw()");
  324. //Customlogic:
  325. //Whenshowingoptionsinthecombo-box,onlyshowtheoptionsfromtheselectedcategory
  326. //ifappropriate
  327. findForm.getItem("itemName").addProperties({
  328. getPickListFilterCriteria:function(){
  329. varcriteria=this.Super("getPickListFilterCriteria",arguments);
  330. if(this.form.getValue('findInCategory')&&categoryTree.selection.anySelected()){
  331. criteria.category=categoryTree.getSelectedRecord().categoryName;
  332. }
  333. returncriteria
  334. }
  335. });
  336. categoryTree.fetchData();
  337. java代碼
  338. DAO層
  339. packageisc.java.Dao;
  340. importisc.java.Module.supplyItem;
  341. importjava.util.List;
  342. importorg.hibernate.SessionFactory;
  343. importorg.springframework.beans.factory.annotation.Autowired;
  344. importorg.springframework.orm.hibernate3.HibernateTemplate;
  345. importorg.springframework.stereotype.Repository;
  346. @Repository
  347. publicclasssupplyItem_Dao{
  348. privateHibernateTemplatehibernateTemplate;
  349. @SuppressWarnings("unused")
  350. @Autowired
  351. privatevoidsetHibernateTemplate(SessionFactorysessionFactory){
  352. this.hibernateTemplate=newHibernateTemplate(sessionFactory);
  353. }
  354. /*
  355. *functionfindAll
  356. *查询supplyItem表中所有记录
  357. *并以list形式返回
  358. *
  359. **/
  360. @SuppressWarnings("unchecked")
  361. publicList<supplyItem>findAll(Stringcategory){
  362. Stringhql="fromsupplyItemwherecategory='"+category+"'";
  363. Listlist=this.hibernateTemplate.find(hql);
  364. returnlist;
  365. }
  366. /*
  367. *根据category返回对应的记录
  368. **/
  369. @SuppressWarnings("unchecked")
  370. publicsupplyItemfindInfoByID(intitemID){
  371. supplyItemsupp=(supplyItem)this.hibernateTemplate.get(supplyItem.class,itemID);
  372. returnsupp;
  373. }
  374. /*
  375. *删除指定记录
  376. *
  377. **/
  378. publicvoiddeleteInfo(supplyItemsupp){
  379. this.hibernateTemplate.delete(supp);
  380. }
  381. /*
  382. *更新修改后的记录
  383. **/
  384. publicvoidupdateInfo(supplyItemsupp){
  385. this.hibernateTemplate.update(supp);
  386. }
  387. /*
  388. *增加记录
  389. **/
  390. publicvoidinsertInfo(supplyItemsupp){
  391. this.hibernateTemplate.save(supp);
  392. }
  393. }
  394. packageisc.java.Dao;
  395. importisc.java.Module.supplyCategory;
  396. importjava.util.List;
  397. importorg.hibernate.SessionFactory;
  398. importorg.springframework.beans.factory.annotation.Autowired;
  399. importorg.springframework.orm.hibernate3.HibernateTemplate;
  400. importorg.springframework.stereotype.Repository;
  401. @Repository
  402. publicclasssupplyCategory_Dao{
  403. privateHibernateTemplatehibernateTemplate;
  404. @SuppressWarnings("unused")
  405. @Autowired
  406. privatevoidsetHibernateTemplate(SessionFactorysessionFactory){
  407. this.hibernateTemplate=newHibernateTemplate(sessionFactory);
  408. }
  409. @SuppressWarnings("unchecked")
  410. publicList<supplyCategory>findAll(StringparentId){
  411. Stringhql="fromsupplyCategorywhereparentId='"+parentId+"'";
  412. Listlist=this.hibernateTemplate.find(hql);
  413. returnlist;
  414. }
  415. }
  416. ENTITY層
  417. packageisc.java.Module;
  418. importjavax.persistence.Column;
  419. importjavax.persistence.Entity;
  420. importjavax.persistence.Id;
  421. importjavax.persistence.Table;
  422. @Entity
  423. @Table(name="supplyCategory")
  424. publicclasssupplyCategory{
  425. privateStringcategoryName;
  426. privateStringparentId;
  427. @Id
  428. @Column(name="categoryName")
  429. publicStringgetCategoryName(){
  430. returncategoryName;
  431. }
  432. publicvoidsetCategoryName(StringcategoryName){
  433. this.categoryName=categoryName;
  434. }
  435. @Column(name="parentId")
  436. publicStringgetParentId(){
  437. returnparentId;
  438. }
  439. publicvoidsetParentId(StringparentId){
  440. this.parentId=parentId;
  441. }
  442. }
  443. packageisc.java.Module;
  444. importjavax.persistence.Column;
  445. importjavax.persistence.Entity;
  446. importjavax.persistence.GeneratedValue;
  447. importjavax.persistence.Id;
  448. importjavax.persistence.Table;
  449. @Entity
  450. @Table(name="supplyItem")
  451. publicclasssupplyItem{
  452. privateintitemID;
  453. privateStringitemName;
  454. privatedoubleunitCost;
  455. privateStringSKU;
  456. privateStringdescription;
  457. privateStringcategory;
  458. privateStringinStock;
  459. privateStringnextShipment;
  460. @Id
  461. @GeneratedValue
  462. @Column(name="itemID")
  463. publicintgetItemID(){
  464. returnitemID;
  465. }
  466. publicvoidsetItemID(intitemID){
  467. this.itemID=itemID;
  468. }
  469. @Column(name="itemName")
  470. publicStringgetItemName(){
  471. returnitemName;
  472. }
  473. publicvoidsetItemName(StringitemName){
  474. this.itemName=itemName;
  475. }
  476. @Column(name="unitCost")
  477. publicdoublegetUnitCost(){
  478. returnunitCost;
  479. }
  480. publicvoidsetUnitCost(doubleunitCost){
  481. this.unitCost=unitCost;
  482. }
  483. @Column(name="SKU")
  484. publicStringgetSKU(){
  485. returnSKU;
  486. }
  487. publicvoidsetSKU(Stringsku){
  488. SKU=sku;
  489. }
  490. @Column(name="description")
  491. publicStringgetDescription(){
  492. returndescription;
  493. }
  494. publicvoidsetDescription(Stringdescription){
  495. this.description=description;
  496. }
  497. @Column(name="category")
  498. publicStringgetCategory(){
  499. returncategory;
  500. }
  501. publicvoidsetCategory(Stringcategory){
  502. this.category=category;
  503. }
  504. @Column(name="instock")
  505. publicStringgetInStock(){
  506. returninStock;
  507. }
  508. publicvoidsetInStock(StringinStock){
  509. this.inStock=inStock;
  510. }
  511. @Column(name="nextShipment")
  512. publicStringgetNextShipment(){
  513. returnnextShipment;
  514. }
  515. publicvoidsetNextShipment(StringnextShipment){
  516. this.nextShipment=nextShipment;
  517. }
  518. }
  519. Service層
  520. packageisc.java.Service;
  521. importisc.java.Dao.supplyCategory_Dao;
  522. importisc.java.Module.supplyCategory;
  523. importjava.util.List;
  524. importorg.springframework.beans.factory.annotation.Autowired;
  525. importorg.springframework.stereotype.Service;
  526. importorg.springframework.transaction.annotation.Transactional;
  527. @Service
  528. publicclasssupplyCategory_Service{
  529. privatesupplyCategory_DaosupplyCategory_dao;
  530. @Autowired
  531. publicvoidsetSupplyCategory_dao(supplyCategory_DaosupplyCategory_dao){
  532. this.supplyCategory_dao=supplyCategory_dao;
  533. }
  534. @Transactional("demoApp")
  535. publicList<supplyCategory>findAll(StringparentId){
  536. returnthis.supplyCategory_dao.findAll(parentId);
  537. }
  538. }
  539. packageisc.java.Service;
  540. importisc.java.Dao.supplyItem_Dao;
  541. importisc.java.Module.supplyItem;
  542. importjava.util.List;
  543. importorg.springframework.beans.factory.annotation.Autowired;
  544. importorg.springframework.stereotype.Service;
  545. importorg.springframework.transaction.annotation.Transactional;
  546. @Service
  547. publicclasssupplyItem_Service{
  548. privatesupplyItem_DaosupplyItem_dao;
  549. @Autowired
  550. publicvoidsetSupplyItem_dao(supplyItem_DaosupplyItem_dao){
  551. this.supplyItem_dao=supplyItem_dao;
  552. }
  553. /*
  554. *使用声明式事物管理
  555. *在业务方法上进行@Transactional注解
  556. *将事物规则应用到业务逻辑中
  557. *demoApp为限定词*_*
  558. **/
  559. @Transactional("demoApp")
  560. publicList<supplyItem>findAll(Stringcategory){
  561. returnthis.supplyItem_dao.findAll(category);
  562. }
  563. @Transactional("demoApp")
  564. publicsupplyItemfindInfoByID(intitemID){
  565. returnthis.supplyItem_dao.findInfoByID(itemID);
  566. }
  567. @Transactional("demoApp")
  568. publicvoiddeleteInfo(intitemID){
  569. supplyItemsupp=this.supplyItem_dao.findInfoByID(itemID);
  570. this.supplyItem_dao.deleteInfo(supp);
  571. }
  572. @Transactional("demoApp")
  573. publicvoidupdateInfo(supplyItemsupp){
  574. this.supplyItem_dao.updateInfo(supp);
  575. }
  576. @Transactional("demoApp")
  577. publicvoidinsertInfo(supplyItemsupp){
  578. this.supplyItem_dao.insertInfo(supp);
  579. }
  580. }
  581. Web層
  582. packageisc.java.Web;
  583. importisc.java.Module.supplyCategory;
  584. importisc.java.Service.supplyCategory_Service;
  585. importjava.io.IOException;
  586. importjava.util.Enumeration;
  587. importjava.util.Iterator;
  588. importjava.util.List;
  589. importjavax.servlet.ServletOutputStream;
  590. importjavax.servlet.http.HttpServletRequest;
  591. importjavax.servlet.http.HttpServletResponse;
  592. importorg.springframework.beans.factory.annotation.Autowired;
  593. importorg.springframework.stereotype.Controller;
  594. importorg.springframework.web.bind.annotation.RequestMapping;
  595. @Controller
  596. publicclasssupplyCategory_Controller{
  597. privatesupplyCategory_ServicesupplyCategory_service;
  598. @Autowired
  599. publicvoidsetSupplyCategory_service(
  600. supplyCategory_ServicesupplyCategory_service){
  601. this.supplyCategory_service=supplyCategory_service;
  602. }
  603. @SuppressWarnings("unchecked")
  604. @RequestMapping(value="demoApp/findTreeAll.action")
  605. publicvoidfindAll(HttpServletResponseresponse,HttpServletRequestrequest){
  606. StringparentId=request.getParameter("parentID");
  607. List<supplyCategory>list=this.supplyCategory_service.findAll(parentId);
  608. ServletOutputStreamsos=null;
  609. try{
  610. sos=response.getOutputStream();
  611. }catch(IOExceptione){
  612. //TODOAuto-generatedcatchblock
  613. e.printStackTrace();
  614. }
  615. StringBuffersbu=newStringBuffer();
  616. Iteratorita=(Iterator)list.iterator();
  617. while(ita.hasNext()){
  618. supplyCategorysupplycategory=(supplyCategory)ita.next();
  619. sbu.append("<country>");
  620. sbu.append("<categoryName>"+supplycategory.getCategoryName()+"</categoryName>");
  621. sbu.append("<parentId>"+supplycategory.getParentId()+"</parentId>");
  622. sbu.append("</country>");
  623. }
  624. try{
  625. sos.print("<?xmlversion='1.0'encoding='UTF-8'?><records>"+sbu.toString()+"</records>");
  626. }catch(IOExceptione){
  627. //TODOAuto-generatedcatchblock
  628. e.printStackTrace();
  629. }
  630. }
  631. }
  632. packageisc.java.Web;
  633. importisc.java.Module.supplyItem;
  634. importisc.java.Service.supplyItem_Service;
  635. importjava.io.IOException;
  636. importjava.util.Iterator;
  637. importjava.util.List;
  638. importjavax.servlet.ServletOutputStream;
  639. importjavax.servlet.http.HttpServletRequest;
  640. importjavax.servlet.http.HttpServletResponse;
  641. importorg.springframework.beans.factory.annotation.Autowired;
  642. importorg.springframework.stereotype.Controller;
  643. importorg.springframework.web.bind.annotation.RequestMapping;
  644. @Controller
  645. publicclasssupplyItem_Controller{
  646. privatesupplyItem_ServicesupplyItem_service;
  647. @Autowired
  648. publicvoidsetSupplyItem_service(supplyItem_ServicesupplyItem_service){
  649. this.supplyItem_service=supplyItem_service;
  650. }
  651. /*
  652. *从数据库中提取数据以xml格式存储
  653. *
  654. **/
  655. @SuppressWarnings("unchecked")
  656. @RequestMapping(value="demoApp/findAll.action")
  657. publicvoidfindAll(HttpServletResponseresponse,HttpServletRequestrequest){
  658. Stringcategory=request.getParameter("category");//接受前台传过来的参数
  659. List<supplyItem>list=this.supplyItem_service.findAll(category);
  660. ServletOutputStreamsos=null;
  661. try{
  662. sos=response.getOutputStream();
  663. }catch(IOExceptione){
  664. e.printStackTrace();
  665. }
  666. StringBuffersbu=newStringBuffer();
  667. Iteratorita=(Iterator)list.iterator();
  668. while(ita.hasNext()){
  669. supplyItemsupplyitem=(supplyItem)ita.next();
  670. sbu.append("<country>");
  671. sbu.append("<itemID>"+supplyitem.getItemID()+"</itemID>");
  672. sbu.append("<itemName>"+supplyitem.getItemName()+"</itemName>");
  673. sbu.append("<unitCost>"+supplyitem.getUnitCost()+"</unitCost>");
  674. sbu.append("<SKU>"+supplyitem.getSKU()+"</SKU>");
  675. sbu.append("<description>"+supplyitem.getDescription()+"</description>");
  676. sbu.append("<category>"+supplyitem.getCategory()+"</category>");
  677. sbu.append("<inStock>"+supplyitem.getInStock()+"</inStock>");
  678. sbu.append("<nextShipment>"+supplyitem.getNextShipment()+"</nextShipment>");
  679. sbu.append("</country>");
  680. }
  681. try{
  682. sos.print("<?xmlversion='1.0'encoding='UTF-8'?><records>"+sbu.toString()+"</records>");
  683. }catch(IOExceptione){
  684. e.printStackTrace();
  685. }
  686. }
  687. @RequestMapping(value="demoApp/deleteInfo.action")
  688. publicvoiddeleteInfo(HttpServletRequestrequest){
  689. intitemID=Integer.parseInt(request.getParameter("itemID"));
  690. System.out.println("test======================"+itemID);
  691. this.supplyItem_service.deleteInfo(itemID);
  692. }
  693. @RequestMapping(value="demoApp/updateInfo.action")
  694. publicvoidupdateInfo(HttpServletRequestrequest){
  695. intitemID=Integer.parseInt(request.getParameter("itemID"));
  696. supplyItemsupp=this.supplyItem_service.findInfoByID(itemID);
  697. supp.setSKU(request.getParameter("SKU"));
  698. supp.setCategory(request.getParameter("category"));
  699. supp.setDescription(request.getParameter("description"));
  700. supp.setInStock(request.getParameter("inStock"));
  701. supp.setItemName(request.getParameter("itemName"));
  702. supp.setNextShipment(request.getParameter("nextShipment"));
  703. Strings=request.getParameter("unitCost");
  704. supp.setUnitCost(Double.parseDouble(s));
  705. this.supplyItem_service.updateInfo(supp);
  706. }
  707. @RequestMapping(value="demoApp/insertInfo.action")
  708. publicvoidinsertInfo(HttpServletRequestrequest){
  709. supplyItemsupp=newsupplyItem();
  710. supp.setCategory(request.getParameter("category"));
  711. supp.setSKU(request.getParameter("SKU"));
  712. supp.setDescription(request.getParameter("description"));
  713. supp.setInStock(request.getParameter("inStock"));
  714. supp.setItemName(request.getParameter("itemName"));
  715. supp.setNextShipment(request.getParameter("nextShipment"));
  716. supp.setUnitCost(Double.parseDouble(request.getParameter("unitCost")));
  717. this.supplyItem_service.insertInfo(supp);
  718. }
  719. }
  720. Xml
  721. App-config.xml
  722. <?xmlversion="1.0"encoding="UTF-8"?>
  723. <beansxmlns="http://www.springframework.org/schema/beans"
  724. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  725. xmlns:mvc="http://www.springframework.org/schema/mvc"
  726. xmlns:context="http://www.springframework.org/schema/context"
  727. xsi:schemaLocation="
  728. http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  729. http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd
  730. http://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
  731. <!--Scanstheclasspathofthisapplicationfor@Componentstodeployasbeans-->
  732. <!--規約所有進行掃描的類,以完成Bean創建和自動依賴注入功能-->
  733. <context:component-scanbase-package="isc.java.*"/>
  734. <!--<context:annotation-config/>-->
  735. <!--Configuresthe@Controllerprogrammingmodel-->
  736. <mvc:annotation-driven/>
  737. <!--misc-->
  738. <beanid="viewResolver"class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  739. <propertyname="viewClass"value="org.springframework.web.servlet.view.JstlView"/>
  740. <propertyname="suffix"value=".action"/>
  741. </bean>
  742. <!--ConfiguresHibernate-DatabaseConfig-->
  743. <importresource="db-config.xml"/>
  744. </beans>
  745. Db-config.xml
  746. <?xmlversion="1.0"encoding="UTF-8"?>
  747. <beansxmlns="http://www.springframework.org/schema/beans"
  748. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  749. xmlns:tx="http://www.springframework.org/schema/tx"
  750. xmlns:aop="http://www.springframework.org/schema/aop"
  751. xsi:schemaLocation="
  752. http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  753. http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.0.xsd
  754. http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
  755. <beanid="dataSource"class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  756. <propertyname="driverClassName"><value>com.microsoft.sqlserver.jdbc.SQLServerDriver</value></property>
  757. <propertyname="url"><value>jdbc:sqlserver://10.1.100.215:1433;DatabaseName=email</value></property>
  758. <propertyname="username"><value>dev</value></property>
  759. <propertyname="password"><value>12345678aA</value></property>
  760. </bean>
  761. <beanid="sessionFactory"class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
  762. <propertyname="dataSource"><reflocal="dataSource"/></property>
  763. <propertyname="packagesToScan"value="isc.java.*"/>
  764. <propertyname="hibernateProperties">
  765. <props>
  766. <propkey="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
  767. <propkey="hibernate.show_sql">true</prop>
  768. <!--<propkey="hibernate.hbm2ddl.auto">update</prop>-->
  769. <propkey="hibernate.format_sql">true</prop>
  770. </props>
  771. </property>
  772. </bean>
  773. <!--TransactionmanagerforasingleHibernateSessionFactory(alternativetoJTA)-->
  774. <tx:annotation-driven/>
  775. <beanid="transactionManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  776. <propertyname="sessionFactory"><reflocal="sessionFactory"/></property>
  777. <qualifiervalue="demoApp"/><!--限定词-->
  778. </bean>
  779. </beans>

 

分享到:
评论

相关推荐

    SmartClient资料

    7. **Smartclient+demo+实例**:提供的示例和演示代码帮助开发者了解SmartClient的实际应用场景,学习如何创建和使用各种组件和功能。 8. **hsql++(the Visual Builder DataSource)**:HSQL是一个轻量级的关系型...

    smartclient demoApp

    《SmartClient DemoApp详解》 SmartClient是一款强大的JavaScript和HTML5客户端开发框架,它提供了丰富的UI组件和数据管理功能,广泛应用于企业级Web应用开发。本文将深入解析名为"smartclient demoApp"的示例应用...

    smartclient demo

    "SmartClient"是一款强大的富客户端应用开发框架,主要用于构建高性能、交互性强的Web应用程序。它提供了丰富的用户界面组件,使得开发者能够快速地创建出复杂的业务逻辑和数据密集型的前端应用。SmartClient的核心...

    java smartclient实例

    在本实例中,我们将探讨如何利用Java SmartClient进行基础的开发工作,以及如何处理缺失的jar包问题。 首先,Java SmartClient的核心是其强大的GWT(Google Web Toolkit)兼容性,这使得开发者可以使用Java语言编写...

    SmartClient

    "SmartClient"是一种在IT行业中常见的术语,通常指的是具有高度智能化和自适应能力的客户端应用程序。这类客户端能够根据用户的行为、环境或者系统状态自动调整其功能和表现,提供更个性化的用户体验。在这个“智能...

    smartclient 结合spring 实例

    本文将详细探讨如何将SmartClient与Spring框架结合,以实现一个测试tree和list组建的应用实例。 首先,我们需要理解SmartClient的核心特性。SmartClient包含一套丰富的JavaScript和Java UI组件库,这些组件可以提供...

    springMVC+hibernate+dwr+smartClient

    **SpringMVC、Hibernate、DWR与SmartClient的整合应用** SpringMVC是Spring框架的一部分,主要用于构建Web应用程序的模型-视图-控制器(MVC)结构。它提供了灵活的控制器,支持多种视图技术,并允许开发者以声明式...

    smartclient视频教程

    SmartClient是一种强大的JavaScript和Java应用程序框架,用于构建高性能、富客户端的Web应用。这个"smartclient视频教程"可能涵盖了从基础到高级的各种主题,帮助学习者深入理解和掌握这个技术。 SmartClient的核心...

    SmartClient UI实例参考

    Smart Client智能客户端就是这样一种一个可扩展的能集成不同应用的桌面应用程序:它可以无接触部署、即需即装、动态加载,XCopy即可运行而无须修改注册表,可以动态升级、自动更新,可以方便的经Web运行而不用担心...

    Smart Client

    **Smart Client架构与设计指南** 智能客户端(Smart Client)是一种软件开发模式,它结合了桌面应用的优势,如离线操作、高性能和丰富的用户界面,同时利用互联网连接来获取实时数据和更新。Smart Client架构旨在...

    智能客户端(Smart Client)中文文档及案例

    智能客户端(Smart Client)是一种软件开发模式,它旨在提供更高效、更个性化、更互动的用户体验,尤其是在企业级应用中。这种技术强调利用本地计算资源,如存储、内存和处理器性能,来提升应用程序的响应速度和功能...

    关于Smart Client的学习例子

    在IT行业中,Smart Client是一种应用程序开发模式,它旨在提供比传统的 Thick Client(胖客户端)或 Thin Client(瘦客户端)更为智能、自适应和高效的用户体验。Smart Client应用通常结合了本地计算能力和网络通信...

    smartclient的一个例子,很精典(源码)

    SmartClient是一种强大的JavaScript和Java框架,用于构建高性能的富客户端Web应用。这个压缩包包含的是SmartClient的一个经典示例,提供了源代码供学习和参考。SmartClient的核心特性在于它的组件库、数据绑定机制...

    SmartClient框架组件介绍中文帮助

    `Class`是所有SmartClient组件的基类,提供了创建类实例、添加方法和属性的功能。通过继承和组合,开发者可以构建复杂的组件结构。例如,`Timer`组件就是基于`Class`构建的,它实现了定时任务的执行,可以用于定时...

    smart client安卓系统的安装包

    smart client安卓系统的安装包

    SmartClient js框架源码

    SmartClient JavaScript框架是一款强大的富客户端应用开发工具,它提供了丰富的组件库、数据绑定机制和高度可定制的界面,使得开发者可以构建高性能、交互性强的Web应用程序。源码分析是理解框架内部工作原理的关键...

    西门子3个SMART plc+触摸屏控制7台松下A5伺服

    标题中的“西门子3个SMART plc+触摸屏控制7台松下A5伺服”描述了一个工业自动化系统,其中三个西门子SMART系列的可编程逻辑控制器(PLC)与一个触摸屏配合,用于控制七台松下A5系列的伺服电机。这个系统涉及到的主要...

    smartclient

    ### SmartClient:构建高效Web应用的关键技术 #### 引言 SmartClient是由Isomorphic Software开发的一款先进的企业级Web应用程序框架,旨在提供卓越的用户界面体验和高性能的数据处理能力。自2001年首次发布以来,...

    Smart Client技术应用

    Smart Client技术是一种旨在结合传统胖客户端(C/S架构)的强大功能和瘦客户端(B/S架构)的便捷部署与管理优势的客户端技术。它通过优化资源利用,为用户提供更丰富的交互体验,同时降低对系统资源的需求。 Smart ...

Global site tag (gtag.js) - Google Analytics