업무관련/넥사크로

넥사크로로 popup 실행해서 제어하는 방법

레임보우 2023. 7. 12. 09:37

 

 

Popup_Nexacro.jsp 또는 html로 만든다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.*"%>
<%
    // 고유한 세션 객체의 ID를 되돌려준다.
    String id_str = session.getId();
 
    // 세션에 마지막으로 엑세스한 시간을 되돌려 준다.
    long lasttime = session.getLastAccessedTime();
   
    // 세션이 생성된 시간을 되돌려 준다.
    long createdtime = session.getCreationTime();
   
    // 세션에 마지막으로 액세스한 시간에서 세션이 생성된 시간을 빼면 웹 사이트에 머문 시간이 계산된다.
    long time_used = (lasttime - createdtime) / 60000;
   
    // 세션의 유효 시간 얻어오기
    int inactive = session.getMaxInactiveInterval() / 60;
   
    // 세션이 새로 만들어졌는지를 알려준다.
    boolean b_new = session.isNew();
%>
<!doctype html>
<html>
 
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    
    <title>결재창</title>
</head>
 
<body>
    <div >
        <h1>결제중</h1>
        <h1>이창을 닫지 마세요</h1>
        <!--
        <h1><%=id_str%></h1>
        <h1><%=b_new%></h1>
        -->
    </div>
    <script>
        let NexPopUp;
 
        if (!window.NEXACROHTML) {
            window.NEXACROHTML = {};
        }
 
        // 키와 데이터를 전달
        window.NEXACROHTML.FireUserNotify = function (sAddr,sData) {
            var arrData = new Array();
            arrData[0]= sAddr; // Key
            arrData[1]= sData; // Value
 
            if (window.NEXACROWEBBROWSER) {
                window.NEXACROWEBBROWSER.on_fire_onusernotify(window.NEXACROWEBBROWSER, arrData);
            }
        }
 
 
        // 새로운 팝업창에 올림
        function fnCallPopUp(arrInfo) {
            var hostUrl =  document.location.protocol +"//"+document.location.host;
            console.log(hostUrl);
            //alert(hostUrl);
            //var url = "http://"+hostUrl+"/kcu/pay/INIstdpay_pc_req.jsp?";
            var url = hostUrl+"/kcu/chat/lmsChat.html?";
            var name = "lmsChat";
            var option = "width = 1000, height = 800, top = 100, left = 200, location = no";
            // 파라메터 입력
            for (let index = 0; index < arrInfo.length; index++) {
                url+=arrInfo[index][0]+"="+arrInfo[index][1]+"&";
            }
            //alert(url);
            NexPopUp=window.open(url, name, option);
            setTimeout(fnIsPopupClosed, 1000);
        }
 
        // 팝업창이 떠있는지 확인해서 없으면 사용자가 팝업창을 강제로 닫은거임
        function fnIsPopupClosed() {
            if(NexPopUp.closed)
            {
                fnFromPopup("PopupClose","0");
            }
            else{
                setTimeout(fnIsPopupClosed, 1000);
            }
            
        }
        
 
        // 팝업으로 보내기
        function fnToPopup(x) {
            NexPopUp.document.getElementsByName("buyertel")[0].value=x;
        
        }
 
        // 팝업에서 받기
        function fnFromPopup(key,val) {
            window.NEXACROHTML.FireUserNotify(key,val);
        }
 
        // 팝업 닫기
        function fnFromPopupCloseMe() {
            NexPopUp.close();
        }
 
        
 
    </script>
</body>
 
</html>
cs

 

 

 

 

넥사크로에는 아래와 같이 webBrowser 컴포넌트와 이벤트 2개를 생성한다.

팝업을 띄우고 싶은 부모화면 안에 추가해야함.

 

 

 

넥사크로 코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
this.divMain_btnIntoChat00_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo)
{
 
        if(this.dsList.rowcount==0)
        {
            return;
        }
        
        // 팝업을 실행시키기
        var objEnv = nexacro.getEnvironment();
        var sUrl = objEnv.services['exlUrl'].url;// + "/addr/postcode.jsp";
        trace("aa : "+sUrl); // http://localhost:8088/kcu/
 
        this.divMain.form.web00.set_url(sUrl+"chat/lmsChat_Nexacro.jsp");
};
 
 
 
// 웹이 성공적으로 열렸을때 html에 아래 파라미터를 넣고 호출할수 있다. 
this.web00_onloadcompleted = function(obj:nexacro.WebBrowser,e:nexacro.WebLoadCompEventInfo)
{
    trace("web00_onloadcompleted :"+e.url);
    
    // url에 파라메터로 넘길값
    var arrList = new Array();
    
    // 참가자명
    var arrKeyVal = new Array("NAME",this.dsSearch.getColumn(0,"USER_NAME"));
    arrList.push(arrKeyVal);
    
    // 학년도 학기명 EX)2023학년도 1학기
    arrKeyVal = new Array("SMST_NM",this.dsList.getColumn(0,"SHYR")+"학년도 "+this.dsList.getColumn(0,"SMST_NM"));
    arrList.push(arrKeyVal);
    
    
    // 과목명
    arrKeyVal = new Array("DERT_NM",this.dsList.getColumn(this.divMain.form.cboSubj.index,"SUBJ_KORN_NM"));
    arrList.push(arrKeyVal);
    
    
    
    // 과목코드 (방번호지정됨)
    arrKeyVal = new Array("DERT_CD",this.dsList.getColumn(this.divMain.form.cboSubj.index,"COSE_CD"));
    arrList.push(arrKeyVal);
    
    
    // 과목기본정보명
    var sInfoString = "";
    sInfoString += this.dsList.getColumn(this.divMain.form.cboSubj.index,"COPL_SE_NM")+" / ";
    sInfoString += this.dsList.getColumn(this.divMain.form.cboSubj.index,"BAN")+"반 / ";
    sInfoString += this.dsList.getColumn(this.divMain.form.cboSubj.index,"PROFINSTR_NM")+"교수님 / ";
    sInfoString += this.dsList.getColumn(this.divMain.form.cboSubj.index,"PNT_SCOR")+"학점";
    
    arrKeyVal = new Array("DERT_INFO",sInfoString);
    arrList.push(arrKeyVal);
    
    
    trace(arrList);
    
    
        
    // web에 결재정보 보내기
    // OID  년월일시분초학년도학기학번 2023061314353920221022134061
    var _doc = this.divMain.form.web00.getProperty("window");
    _doc.callMethod("fnCallPopUp", arrList);
    
    
    if(_doc){
        _doc.destroy();
        _doc = null;
    }
};
 
 
 
 
// html에서 받아올수도 있다.
this.web00_onusernotify = function(obj:nexacro.WebBrowser,e:nexacro.WebUserNotifyEventInfo)
{
    switch(e.userdata[0]) {
    case "visibilityState"// visible, hidden
        if(e.userdata[1]=="visible")
        {
            // 작업
        }
        else
        {
            // 작업    
        }
        break;
    case "videoState":
        if(e.userdata[1]=="pause")
        {
            // 작업
        }
        else
        {
            // 작업    
        }
        
        break;
    default:
        break;
    }
};
 
 
this.fnPopClose = function ()
{
    // 여기서 팝업을 닫을수도 있다.
    var _doc = this.divMain.form.web00.getProperty("window");
    _doc.callMethod("fnFromPopupCloseMe");
    
    
    if(_doc){
        _doc.destroy();
        _doc = null;
    }
};
 
 
 
cs

 

이렇게 해야 넥사크로의 팝업을 제어할수 있고 데이터도 받을수 있음