博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Tips of ACWS Framework
阅读量:5923 次
发布时间:2019-06-19

本文共 9332 字,大约阅读时间需要 31 分钟。

ACWS Framework - Tips

 
Note:
Important Level divides 5 layers, deep as 1 to 5.
 
DWR Part
The framework have been integrated DWR for communicate between JS and Java code, Here we needn’t talk because it so easy, have a short learning.
More info:   
http://directwebremoting.org/dwr/index.html
 
ExtJS Part
Base
1. Window
Code Exp:
---------------------------
    var win;
//search win
    win = _window("search_window");
    win.addButton('Confirm',beginSearch);
    win.addButton('Cancel',closeWin);
      
<div id="search_window" class="x-hidden" title="Search" modal=true>
    <div class="x-window-body">
       <iframe src="" id="embedHtm" name="embedHtm" ></iframe>
    </div>
</div>
---------------------------
When need to show win, you have to set frame’s src to a html form or page, in other hand, you also can write this form or page in frame line directly.
Code Exp:
---------------------------
document.getElementById("embedHtm").src=”/projectweb/pages/artAdd.htm”;
//cancel action
win.addButton('Close',function(){
win.hide();mygrid.beginPageLoad();});
//show pop win
win.show();
---------------------------
 
2. Grid
Create grid in ACWS like this,
Code Exp:
---------------------------
//grid
grid = paggingGrid('t','gridbox',menugrid,mygrid,
'/acwsui/images/imgs/',false);
document.getElementById("gridbox").style.height = (top.window.document.body.clientHeight||window.document.body.clientHeight) - 26 - 24 - 21 - 20-110;
mygrid = grid.mygrid;
//Multi Select Mode
mygrid.enableMultiselect(false);
jsoa.PAGESIZE = 20;
jsoa.PAGEELEMENT = 10;
   
//load data
mygrid.beginPageLoad();
---------------------------
 
In html page should have the target div for bind JSON data from DWR, the whole format like this,
Code Exp:
---------------------------
<!-- grid -->
<div id="gridbox" width="100%" height="405px" style="float: left">
<!—- class attribute is important -->
    <table id="t" border=0 class="OnRowSelect=rowSelect"
                  style="display: none">
       <thead>
           <tr>                
              <!-- Title -->
              <td align="center" valign="middle">
                     No
              </td>
 
              <td align="center" valign="middle">
                     Name
              </td>
           </tr>
           <!—class as to JSON data’s key -->
           <tr class=BO_BTS_GH_ID id=prc>
              <td width=5 align=left abbr=ro class=RN></td>
              <td width=10 align=left abbr=ro class=Data_Name></td>
           </tr>
       </thead>
    </table>
</div>
<!—- Bind data by DWR -->
<div id="gridbox_page" totalfun="ArtManage.getCountWithPara"
       pagefun="ArtManage.getCurrentWithPara" parmarobj="jsoa"></div>
---------------------------
Above code show is a typical grid code template, if you want to add a tool bar, a bar above the grid for show function buttons like Search, Add, Edit, Import, Export even add a checkbox list if you want, code like this,
Code Exp:
-----------------------------
//set tool bar
var text = '<select name="YJ_ORDER" id="YJ_ORDER" οnchange="addOrderFiled()"></select>';
buttonList = _changeHtmlButtonToExtToolbar("toolbar",text);
-----------------------------
As you see, the key is function from frame work called
 “_changeHtmlButtonToExtToolbar.”, while in html page, you also should have the bar target for binding, code like this,
Code Exp:
-----------------------------
<!-- Tool Bar -->
<div class="lable-tagbartd">
    <div id="toolbar">
<input type=button buttonId="search" img="/projectweb/images/search.gif" value="Search"
           style="display: none">
    </div>
</div>
-----------------------------
 
3. Include html by iframe
Which common use in JS functions as set some element’s src attribute to a URL, and the URL is a html page, may be is form to accept users entering, upload or download, which can be used in pop window and main tab as to the form items is big enough or not.
Which can do call switch between itself and parent, detail way info please go ahead.
 
4. Parent & Child call switch
If a html page have been include by some frame, and show as pop window, so in this html page you can use this way
Code Exp:
-----------------------------
window.parent.win.hide();
window.parent.mygrid.beginPageLoad();
-----------------------------
To call which parent – pop window’s attribute, object or function, like this win object and mygrid object, hide and beginPageLoad function.
 
In other hand, in parent call child, you can use the frame’s id to get the include-page object, then call elements (function, attribute, object etc) directly, code like this,
Code Exp:
-----------------------------
embedHtm.winSave();
win.hide();
mygrid.beginPageLoad();
-----------------------------
 
Data Convert
1. changeFormToJSO
Change form items to JSON format data, which is frame work level embed JS function, use for get page form value and change into JSON format.
 
2.changeJSOToForm
Similar with changeFormToJSO.
 
3.getQueryString("pid")
This function can be used as get http request parameters by get way.
 
4.fillJSOInToSpan(jso,"textspan")
Fill JSON format data into html page’s span DOM tag, which often use in callback function.
Code Exp:
-----------------------------
ArtManage.getDetailInfo(appid,function(jso){
       fillJSOInToSpan(jso,"textspan");
});
-----------------------------
 
Component
1.    
WdatePicker
Date picker component, which is an pop box for you choose date.
Code Exp:
<script src="/acwsui/js/DatePicker/WdatePicker.js"
 type="text/javascript" ></script>
<input type="text" name="BTS_GH_JSSJ" id="BTS_GH_JSSJ"  class="Wdate"
 οnfοcus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy
MM
'})"
style="background-color: white;" readonly />
-----------------------------
 
2.
 
Other Skills
1. OnRowSelect=rowSelect|SplitAt=4
Code Exp:
-----------------------------
<div id="gridbox" title="country table" modal=true>
<div class="x-window-body">
<table id="t" border=0 class="OnRowSelect=rowSelect|SplitAt=4"
    style="display: block">
<tr class=BTS_ID >
       <td width=70px align=left abbr=ro class=RN></td>
</tr>
-----------------------------
This setting can fixed the location of column in grid dragging process, beside set it, the code “id=prc” should be delete to avoid the columns width by percentage.
 
2._addExtButton('btnSearch','serbtn2','Search',beginSearch);
This can add a button and bind a callback function on it.
Code Exp:
-----------------------------
<td id='btnSearch'></td>
-----------------------------
 
3.window.top.PageBus
PageBus is a tool of ACWS framework, by with you can transfer the current page’s form elements include which values to any other page, in the page you can use this
Code Exp:
-----------------------------
//Set Form Data into bus
function publishMessage(){
    window.top.PageBus.publish('com.pageBus', changeFormToJSO());
}
//get from bus
function init(){
window.top.PageBus.subscribe("com.pageBus", null, onMessage, null);
}
function onMessage(subj, msg, data){
document.forms[0].messageInfo.value = document.forms[0].messageInfo.value + "\r\n" +
"User Name is : " + msg.userName + "\r\n" +
"Password is : " + msg.password;
}
-----------------------------
In fact, PageBus is a top container to hold some variables then support handlers for user to operate those variables, which is a framework level layer container.
 
4.JS operate DOM timely (K5)
This is very very important point skill in JS & DOM tree operation.
Code Exp:
-----------------------------
HTML CODE
<body οnlοad=””>
...
<div id="search_window" title="Search" modal=true>
<div class="x-window-body">
     <table cellspacing="0" class="table-width">
           <tr>
              <td>
              <input type="checkbox"  id="BTS_FZ_GYF"  name="BTS_FZ_GYF" value="15117" >
电信
              <input type="checkbox"  id="BTS_FZ_GYF"   name="BTS_FZ_GYF" value="15121" >
移动
              <input type="checkbox"  id="BTS_FZ_GYF"   name="BTS_FZ_GYF" value="15125" >
联通
              <input type="checkbox"  id="BTS_FZ_GYF"   name="BTS_FZ_GYF" value="15129" >
华数
              </td>
           </tr>
</table>
</div>
</div>
<input type=button buttonId="search" img="images/search.gif" value=" Search" style="display: none">
...
</body>
 
JS CODE
var win;
function init() {
//search win
    win = _window("search_window");
    win.addButton('Sure',beginSearch);
    win.addButton('Cancel',closeWin);
}
 
//show search win
function showSearchDiv()
{
    win.show();  
//This call must be behind the show action!!
    setSearchWinCK();
}
//Operate DOM in pop window
function setSearchWinCK(){
    if(userFlag=="SUPER_ADMIN"){
       //Node of BTS_FZ_GY
        var sd = document.getElementsByName("BTS_FZ_GYF");
        for (var j=0;j<sd.length;j++) {
             sd[j].checked=true;
        }
    }
}
-----------------------------
As the above show, you must take a look at the function named “showSearchDiv”, the call order of the function, you must first pop up the window, then operate the DOM in this pop window, like check on the check box group, if not, you will find the operate has been done but the DOM status has not been change or some unreasonable status has been show, because the DOM in pop window wasn’t create finished, operate those DOM of course it will not be OK.
In a word, when you do some operate of DOM elements by JS, you must pay enough attention in call order, must in correct time.
 
So to ensure the DOM can be operate while the JS run asynchronous, the DWR framework support us an tool name “DWREngine”, you can do it like this,
Code Exp:
-----------------------------
DWREngine.setAsync(false);
win.show();
DWREngine.setAsync(true);
-----------------------------
This setting can make sure the pop win has been created.
 
In fact, the DWREngine has many using for you, such as beginBatch, setTimeout etc, if you want to know more please see DWR’s js-doc.
 
     本文转自danni505 51CTO博客,原文链接:http://blog.51cto.com/danni505/274387
,如需转载请自行联系原作者
 
你可能感兴趣的文章
今年暑假不AC
查看>>
算法学习之路|A除以B
查看>>
《驾驭大数据》一3.6 博彩业:筹码跟踪数据的价值
查看>>
Resx 文件无效,未能加载 .RESX 文件中使用的类型
查看>>
[J2MEQ&A]WTK初始化WMAClient报错XXX has no IP address的解释
查看>>
29.Flutter与原生解耦式混合开发
查看>>
编码 GBK 的不可映射字符
查看>>
广平县北方计算机第一届PS设计大赛
查看>>
oracle创建dblink
查看>>
smartctl---查看硬件接口
查看>>
深入理解Java的接口和抽象类
查看>>
fail2ban 帮助postfix 过滤恶意IP
查看>>
Simple Proxy Server (Java)
查看>>
Kafka消费的几种方式--low-level SimpleConsumer
查看>>
解决mysql数据库不能支持中文的问题
查看>>
VMware14虚拟机秘钥
查看>>
JVM -verbose参数详解
查看>>
CentOS LInux启动关闭和服务管理
查看>>
Eclipse中10个最有用的快捷键组合
查看>>
java与xml
查看>>