SMTSS00101_이미지처리샘플.xrw 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <?xml version="1.0" encoding="EUC-KR"?>
  2. <?xml-stylesheet type="text/css" href="../../../com/commonweb/css/common.css" ?>
  3. <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2002/01/xforms" xmlns:ev="http://www.w3.org/2001/xml-events">
  4. <xhtml:head>
  5. <xhtml:title>이미지 저장/조회 예제</xhtml:title>
  6. <model id="model1">
  7. <instance id="instance1">
  8. <root xmlns="">
  9. <main>
  10. <list>
  11. <imglist/>
  12. </list>
  13. <view>
  14. <imgnm/>
  15. <imgdata/>
  16. <imgwidth/>
  17. <imgheight/>
  18. </view>
  19. <errorlist>
  20. <error>
  21. <imgnm/>
  22. <errmsg/>
  23. </error>
  24. </errorlist>
  25. <imgnm/>
  26. </main>
  27. <send>
  28. <imgnm/>
  29. <imgdata/>
  30. <imgwidth/>
  31. <imgheight/>
  32. <dellist/>
  33. </send>
  34. <init>
  35. <bizabbr>
  36. <label>com</label>
  37. <value>com</value>
  38. </bizabbr>
  39. <bizabbr>
  40. <label>emr</label>
  41. <value>emr</value>
  42. </bizabbr>
  43. <bizabbr>
  44. <label>pam</label>
  45. <value>pam</value>
  46. </bizabbr>
  47. <msgtype>
  48. <label>error</label>
  49. <value>error</value>
  50. </msgtype>
  51. <msgtype>
  52. <label>info</label>
  53. <value>info</value>
  54. </msgtype>
  55. </init>
  56. <temp/>
  57. <imgdata/>
  58. </root>
  59. </instance>
  60. <script type="javascript" ev:event="xforms-ready">
  61. <![CDATA[
  62. fInitialize();
  63. ]]>
  64. </script>
  65. <submission id="TXTSS00101" mediatype="application/x-www-form-urlencoded" method="post" ref="/root/send" resultref="/root/temp"/>
  66. <submission id="TRTSS00101" mediatype="application/x-www-form-urlencoded" method="post" ref="/root/send" resultref="/root/main/list"/>
  67. <submission id="TRTSS00102" mediatype="application/x-www-form-urlencoded" method="post" ref="/root/send" resultref="/root/main/view"/>
  68. <submission id="TXTSS00102" mediatype="application/x-www-form-urlencoded" method="post" ref="/root/send" resultref="/root/temp"/>
  69. <submission id="TRTSS00103" mediatype="application/x-www-form-urlencoded" method="post"/>
  70. <submission id="TXTSS00103" mediatype="application/x-www-form-urlencoded" method="post" ref="/root/send" resultref="/root/main/errorlist"/>
  71. </model>
  72. <script type="javascript" src="../../../com/commonweb/js/common.js"/>
  73. <script type="javascript" src="../../../com/commonweb/js/tfHelper.js"/>
  74. <script type="javascript">
  75. <![CDATA[
  76. // 화면 open시와 초기화 버튼 클릭시 화면 초기화 기능을 수행한다.
  77. function fInitialize() {
  78. fEnableInsertButton();
  79. model.removeNodeset("/root/main/list/imglist");
  80. model.removeNodeset("/root/main/errorlist/error");
  81. model.resetInstanceNode("/root/send");
  82. model.resetInstanceNode("/root/main/view");
  83. model.refresh();
  84. fChangeImage("../../../com/commonweb/images/no_image.gif");
  85. }
  86. function fChangeImage(imgsrc){
  87. img_hidden.src = imgsrc; // 파일에서 읽은 이미지의 base64 encoding 값을 가져오기 위한 이미지 컨트롤
  88. var data = img_hidden.getbase64data(); // base64 encoding 문자열을 가져온다.
  89. var imgSize = getImageSize(imgsrc);
  90. var imgWidthSize = imgSize.split("^")[0];
  91. var imgHeightSize = imgSize.split("^")[1];
  92. model.setValue("/root/main/view/imgdata",data,true); // 이미지를 보여주기 위하여 view용 이미지컨트롤의 ref instance에 값을 저장
  93. setImageRefInstance("/root/main/view/imgdata");
  94. model.setValue("/root/main/view/imgwidth", imgWidthSize);
  95. model.setValue("/root/main/view/imgheight", imgHeightSize);
  96. if( imgWidthSize <= 340)
  97. img_view.attribute("width")= imgWidthSize;
  98. if( imgWidthSize <= 270)
  99. img_view.attribute("height")= imgHeightSize;
  100. model.refresh();
  101. }
  102. function fEnableInsertButton() {
  103. }
  104. function fEnableUpdateButton() {
  105. }
  106. function fCheckMandatoryInput() {
  107. // 필수항목 체크
  108. if (model.getValue("/root/send/imgnm") == "") {
  109. messageBox("이미지명은","I003");
  110. model.setFocus("cmb_bizabbrinput");
  111. return false;
  112. }
  113. if (model.getValue("/root/main/item/msgtype") == "") {
  114. messageBox("메시지 종류는","I003");
  115. model.setFocus("cmb_msgtypeinput");
  116. return false;
  117. }
  118. if (model.getValue("/root/main/item/msgno") == "") {
  119. messageBox("메시지 번호는","I003");
  120. model.setFocus("ipt_msgnoinput");
  121. return false;
  122. }
  123. if (model.getValue("/root/main/item/msgcnts1") == "") {
  124. messageBox("메시지 1은","I003");
  125. model.setFocus("ipt_imgnminput");
  126. return false;
  127. }
  128. return true;
  129. }
  130. ]]>
  131. </script>
  132. </xhtml:head>
  133. <xhtml:body guideline="1,1194;" style="margin-left:8; margin-top:0; margin-right:8; margin-bottom:0; ">
  134. <group id="group1" style="left:0px; top:0px; width:1195px; height:13px; ">
  135. <caption id="caption6" class="tit_1" style="left:0px; top:0px; width:189px; height:14px; ">이미지 저장/조회 예제</caption>
  136. </group>
  137. <group id="group3" scroll="auto" style="left:0px; top:40px; width:1195px; height:744px; ">
  138. <caption id="caption3" class="cell_1" style="left:765px; top:85px; width:70px; height:285px; vertical-align:middle; ">이미지</caption>
  139. <line id="line3" class="line_2" style="x1:765px; y1:371px; x2:1195px; y2:371px; "/>
  140. <group id="group2" style="left:0px; top:14px; width:1194px; height:35px; vertical-align:top; ">
  141. <shape id="roundrect1" appearance="roundrect" ellipsewidth="10" ellipseheight="10" style="left:0px; top:0px; width:1194px; height:35px; background-color:#fffbf2; border-color:#ffd799; "/>
  142. <caption id="caption2" class="search_name" style="left:16px; top:8px; width:91px; height:17px; ">이미지 명 :</caption>
  143. <line id="line13" style="x1:1106px; y1:7px; x2:1106px; y2:29px; border-color:#ffe4bb; border-left-style:solid; "/>
  144. <input id="ipt_imgnm" ref="/root/main/imgnm" class="input_search" navindex="3" style="left:115px; top:8px; width:200px; height:14px; "/>
  145. <button id="btn_search" class="btn1_letter2" navindex="4" style="left:1122px; top:7px; width:56px; height:22px; ">
  146. <caption>조회</caption>
  147. <script type="javascript" ev:event="DOMActivate">
  148. <![CDATA[
  149. model.makeValue("/root/send/imgnm",model.getValue("/root/main/imgnm"));
  150. model.makeValue("/root/send/imgdata","");
  151. submit("TRTSS00101");
  152. for( var i = grd_imglist.fixedRows ; i < grd_imglist.Rows ; i++ ) {
  153. setImageRefInstance("/root/main/list/imglist["+i+"]/imgdata");
  154. var imgW = model.getValue("/root/main/list/imglist["+i+"]/imgwidth");
  155. var imgH = model.getValue("/root/main/list/imglist["+i+"]/imgheight");
  156. if(grd_imglist.colWidth(2) < imgW)
  157. grd_imglist.colWidth(2) = imgW;
  158. if(grd_imglist.rowHeight(i) < imgH)
  159. grd_imglist.rowHeight(i) = imgH;
  160. }
  161. grd_imglist.rebuild();
  162. model.refresh();
  163. ]]>
  164. </script>
  165. </button>
  166. </group>
  167. <caption id="caption20" class="tit_2" style="left:6px; top:60px; width:118px; height:13px; ">이미지 목록</caption>
  168. <line id="line8" class="line_1" style="x1:0px; y1:77px; x2:760px; y2:77px; "/>
  169. <button id="btn_delete" class="btn5_letter2" style="left:716px; top:56px; width:42px; height:19px; ">
  170. <caption>삭제</caption>
  171. <script type="javascript" ev:event="DOMActivate">
  172. <![CDATA[
  173. model.removeNodeset("/root/main/errorlist/error");
  174. deleteSelectedRows(grd_imglist,false);
  175. model.setValue("/root/send/dellist",grd_imglist.getUpdateData());
  176. submit("TXTSS00102");
  177. ]]>
  178. </script>
  179. </button>
  180. <input id="ipt_imgnminput" ref="/root/main/view/imgnm" class="input_search" navindex="3" style="left:840px; top:375px; width:285px; height:19px; "/>
  181. <line id="line1" class="line_1" style="x1:765px; y1:77px; x2:1194px; y2:77px; "/>
  182. <caption id="caption1" class="tit_2" style="left:765px; top:62px; width:118px; height:14px; ">이미지 보기</caption>
  183. <button id="btn_save" class="btn5_letter2" navindex="13" style="left:1150px; top:57px; width:42px; height:19px; ">
  184. <caption>저장</caption>
  185. <script type="javascript" ev:event="DOMActivate">
  186. <![CDATA[
  187. model.setValue("/root/send/imgnm",model.getValue("/root/main/view/imgnm"));
  188. model.setValue("/root/send/imgdata",model.getValue("/root/main/view/imgdata"),true);
  189. model.setValue("/root/send/imgwidth",model.getValue("/root/main/view/imgwidth"));
  190. model.setValue("/root/send/imgheight",model.getValue("/root/main/view/imgheight"));
  191. submit("TXTSS00101");
  192. ]]>
  193. </script>
  194. </button>
  195. <datagrid id="grd_imglist" nodeset="/root/main/list/imglist" caption="이미지명^미리보기^넓이^높이^최초등록자^등록일자^최종수정자^수정일자" colwidth="237, 100, 100, 100, 100, 100, 100, 100" dataheight="25" defaultrows="0" extendlastcol="scroll" mergecellsfixedrows="bycolrec" rowheader="update" rowheight="25" style="left:0px; top:82px; width:760px; height:299px; border-color:#808080; ">
  196. <col ref="imgnm"/>
  197. <col ref="imgdata"/>
  198. <col ref="imgwidth"/>
  199. <col ref="imgheight"/>
  200. <col ref="errmsg"/>
  201. <col ref="fstrgstdt" format="yyyy-mm-dd"/>
  202. <col ref="lastupdtrid"/>
  203. <col ref="lastupdtdt" format="yyyy-mm-dd"/>
  204. <script type="javascript" ev:event="ondblclick">
  205. <![CDATA[
  206. if( grd_imglist.isCell(event.target) && grd_imglist.row >= grd_imglist.fixedRows ){
  207. var curRow = grd_imglist.row;
  208. model.makeValue("/root/send/imgnm",model.getValue("/root/main/list/imglist["+curRow+"]/imgnm"));
  209. submit("TRTSS00102",false);
  210. setImageRefInstance("/root/main/view/imgdata");
  211. img_view.attribute("width")= model.getValue("/root/main/view/imgwidth");
  212. img_view.attribute("height")= model.getValue("/root/main/view/imgheight");
  213. model.refresh();
  214. }
  215. ]]>
  216. </script>
  217. </datagrid>
  218. <caption id="caption7" class="cell_1" style="left:765px; top:373px; width:70px; height:22px; vertical-align:middle; ">이미지명</caption>
  219. <datagrid id="grd_errlist" nodeset="/root/main/errorlist/error" caption="이미지명^오류메시지" colsep="^" colwidth="338, 398" mergecellsfixedrows="bycolrec" rowsep="|" style="left:0px; top:475px; width:760px; height:150px; ">
  220. <col ref="imgnm"/>
  221. <col ref="errmsg"/>
  222. </datagrid>
  223. <button id="btn_delete2" class="btn5_letter9" style="left:594px; top:56px; width:119px; height:19px; ">
  224. <caption>삭제(트랜젝션 분리)</caption>
  225. <script type="javascript" ev:event="DOMActivate">
  226. <![CDATA[
  227. deleteSelectedRows(grd_imglist,false);
  228. model.setValue("/root/send/dellist",grd_imglist.getUpdateData());
  229. submit("TXTSS00103");
  230. ]]>
  231. </script>
  232. </button>
  233. <caption id="caption4" class="tit_2" style="left:0px; top:453px; width:149px; height:13px; ">이미지 삭제 실패 목록</caption>
  234. <line id="line2" class="line_1" style="x1:0px; y1:470px; x2:760px; y2:470px; "/>
  235. <caption id="caption5" style="left:768px; top:405px; width:426px; height:325px; vertical-align:middle; ">
  236. <![CDATA[이미지를 데이터베이스에 BLOB 필드로 저장관리하는 Sample 프로그램이다.
  237. 또한 UserTransaction에 대한 Sample도 같이 제공한다.
  238. - 조회 : 이미지명에 조회할 이미지 명을 입력하면 Like 검색하여 이미지
  239. 목록으로 출력한다.
  240. - 입력 : 파일 버튼을 클릭하여 입력할 이미지를 선택하고(최대 32KByte)
  241. 이미지 명을 입력한 후 [저장] 버튼을 클릭한다.
  242. - 삭제 : 이미지 목록에서 삭제할 이미지 항목을 선택(여러개 선택 가능)하고
  243. 삭제 버튼을 클릭한다.
  244. - 삭제(트랜젝션 분리) : 서버에서 이미지들을 삭제시 건건에 대하여 별도
  245. 트랜젝션을 걸어서 삭제한다. 삭제 실패한 이미지들은 "이미지 삭제 실패
  246. 목록"에 에러 메시지와 함께 출력된다.
  247. - 관련 컴포넌트 : components/tmp/sampleapp
  248. samplemgr,
  249. webapps/tmp/sampleweb]]>
  250. </caption>
  251. <line id="line7" class="line_3" style="x1:765px; y1:395px; x2:1194px; y2:395px; "/>
  252. <button id="button1" class="btn2_letter4" navindex="13" style="left:1128px; top:374px; width:64px; height:19px; ">
  253. <caption>파일찾기</caption>
  254. <script type="javascript" ev:event="DOMActivate">
  255. <![CDATA[
  256. var file = openImageFileDialog(32768); // image 파일이 너무 크면 submit 시간이 매우 오래(5분이상) 걸리므로 가급적 사이즈를 작게 제한한다.
  257. if (file == "") {
  258. return;
  259. }
  260. fChangeImage(file);
  261. model.setFocus("ipt_imgnminput");
  262. model.refresh();
  263. ]]>
  264. </script>
  265. </button>
  266. <img id="img_view" ref="/root/main/view/imgdata" style="left:845px; top:95px; width:340px; height:270px; background-stretch:stretch; "/>
  267. <img id="img_hidden" visibility="hidden" style="left:845px; top:95px; width:340px; height:270px; "/>
  268. </group>
  269. <group id="group4" scroll="auto" style="left:0px; top:13px; width:1195px; height:27px; ">
  270. <line id="line32" class="line_6" style="x1:0px; y1:25px; x2:1194px; y2:25px; "/>
  271. <button id="btn_init" class="btn4_letter3" navindex="16" style="left:1126px; top:3px; width:68px; height:22px; ">
  272. <caption>초기화</caption>
  273. <script type="javascript" ev:event="DOMActivate">
  274. <![CDATA[
  275. var updtdata = getGridUpdateData(grd_imglist);
  276. if (updtdata != "" ) {
  277. var ret = messageBox("그리드에 작업 중인 내용이 있습니다. 초기화 작업을","Q003");
  278. if (ret != 6) { // not OK
  279. return;
  280. }
  281. }
  282. fInitialize();
  283. ]]>
  284. </script>
  285. </button>
  286. </group>
  287. </xhtml:body>
  288. </xhtml:html>