Domino Tips:Monitoring scheduled agents by e-mail

這一篇文章蠻具啟發性的, 在每支執行完後去記錄執行的時間

然後再安排一支 Agent 每 12 小時檢查一次看 Agent Log 所記錄的執行狀況

來判斷該 Agent 是否執行正常

這可以讓一些重要的 Agent 不會因為不正常的因素沒有執行

而導致系統發生錯誤

蠻值得參考

但有個問題是若檢查的 Agent 本身也沒有執行呢?


原文網址: http://searchdomino.techtarget.com/tip/1,289483,sid4_gci1152535,00.html

Domino Tips:Modifying document item values

通常我們在維護 Notes 資料庫時, 最常遇到的問題就是 User
要求修改表單所填的內容
(不管是你的無心造成他的粗心, 或是它的粗心讓你非常擔心)
這時候我們就要找出來他填值的欄位, 然後把正確的資料塞回去, 再給他 save 起來這樣一個動作 可能就要花您 3~5 分鐘的時間

救星來啦!!

在 SearchDomino 上最近來了一篇文章, 就是來解決這個問題的

他的作法是將文件上的欄位透過 @DocFields 把它取出來放到 List 當中
再透過選取欄位與設定欄位型態的方式
將該欄位的值取出來, 然後再進行修改
整個過程用不到 1 分鐘!!

原文說是給 6.5 使用的, 那廣大的 R5 愛用者怎麼辦?

其實只要將 REM {}; 的部份改成 REM ""; 就可以在 R5.09 使用了!!
最好是將它放在 Agent 中透過動作功能表來使用, 記得要設定為 "執行一次可能會用到 @Command".

原文網址: http://searchdomino.techtarget.com/tip/1,289483,sid4_gci1176004,00.html?track=NL-47&ad=547694HOUSE

Scrollable HTML Table

我們在撰寫網頁時常常會因為資料量的關係使得網頁會超過一個檢視頁,
導致需要使用 scroll bar 將網頁網下捲才能看到全部的資料

有沒有辦法將 HTML Table 作成像 Excel 凍結視窗的方式進行資料的捲動?

上 Google 搜尋 Scrollable HTML Table
你可以找到一大串範例程式可供使用
有的直接對 DOM 操作, 有的透過 iframe 方式來模擬

介紹一個只透過 CSS 的方法, 就可以達成我們的目的了 (參考 LauDean的程式)

美美的 CSS
<style type="text/css">
DIV{
scrollbar-DarkShadow-Color:#9FB7D7;
scrollbar-Track-Color:#F7F7F7;
scrollbar-Face-Color:#C7CFFF;
scrollbar-Shadow-Color:#FFFFFF;
scrollbar-Highlight-Color:#FFFFFF;
scrollbar-3dLight-Color:#C7CFF7;
scrollbar-Arrow-Color:#4F5F87;
}
</style>

表格的部份, 首先將標題的部分獨立出來

<table border="0" cellpadding="0" cellspacing="0" style="border: solid 1px; border-collapse: collapse" width="950">
<tr>
<td valign="top">
<table border="1" cellpadding="0" cellspacing="0" style="border: solid 1px; border-collapse: collapse" width="950">
<tr class="Header">
<td nowrap="nowrap" align="center" width="40">序號<br /> </td>
<td nowrap="nowrap" align="center" width="80">客戶名稱<br /> </td>
<td nowrap="nowrap" align="center" width="50">業務員<br /> </td>
<td nowrap="nowrap" align="center" width="50">客戶<br />類別</td>
<td nowrap="nowrap" align="center" width="70">放款天數<br /></td>
<td nowrap="nowrap" align="center" width="80">A/R 合計<br />(萬元)</td>
<td nowrap="nowrap" align="center" width="90">銷售淨額<br />(萬元)</td>
<td nowrap="nowrap" align="center" width="80">銷售毛利<br />(%)</td>
<td nowrap="nowrap" align="center" width="80">信用額度<br />(萬元)</td>
<td nowrap="nowrap" align="center" width="99">信用評等</td>
<td nowrap="nowrap" align="center" width="99">EPS</td>
<td nowrap="nowrap" align="center" width="60">每股<br />淨值</td>
<td nowrap="nowrap" align="center" width="72">目前<br />股價</td>
</tr>
</table>
</td>
</tr>

再來將內容的 table 部份包裝在 Contain 的<div></div>之中, 將 <div> style 中的 overflow 功能 on 起來,

x 表示水平捲軸, y 表示垂直捲軸

scroll 表示強迫出現捲軸

auto 表示當內容超過現訂範圍時, scroll bar才會出現

<tr>
<td width="*" valign="top">
<div id="Contain" style="height:290px; overflow-y:scroll; overflow-x:auto; margin-top:-1px;">
<table id="ContentTable" border="1" cellpadding="0" cellspacing="0" style="border: solid 1px;border-collapse: collapse" width="936">
<tr>
<td align="center" width="40"> </td>
<td align="left" width="80"> </td>
<td align="center" width="50"> </td>
<td align="right" width="50"> </td>
<td align="right" width="70"> </td>
<td align="right" width="80"> </td>
<td align="right" width="90"> </td>
<td align="right" width="80"> </td>
<td align="right" width="80"> </td>
<td align="center" width="100"> </td>
<td align="right" width="100"> </td>
<td align="right" width="60"> </td>
<td align="right" width="56"> </td>
</tr>
</table>
</div>
</td>
</tr>
</table>


這樣就可以捲動 HTML 的 table 囉!!

要注意的是由於標題列與內容列是兩個獨立的表格

所以再頁面的呈現上要自行調整每一個 td 的 width 這樣才不會發生上下寬度不一致的窘境

多試幾次就可以調成美美的網頁了

這邊就示範垂直捲軸的作法, 水平捲軸的部份就留給大家自己 try 吧.

收到 Google Page 的 invitation

昨天晚上收到了來自 Google Page 的邀請函


真是令人興奮, 等了一陣子了


據說這是一個大量使用 Ajax 技術的 Web Application, 也被說因此造成 performance 不好


這是 default page 醜醜的,  Anyway 快點將首頁建起來並把操作心得 post 上來唄


Ajax 完成客戶財報查詢

完成了進階查詢的畫面了

 

這個畫面跟之前的那一個是在同一個 page 喔

 

並沒有 reload 過

 

只是運用了 javascript + css 的技巧將查詢條件的 block 作顯示跟隱藏

 

基本的架構還是一樣 透過 XHTTP 去要後端的資料

只不過這次的資料是經過繁複計算的

 

但是只要你查過的資料就會被 cache 住, 這樣別人再查時

資料就是即時出現囉

 

同時在 XHTTP 去要資料時, 可以在 Client 端作一些像 progress bar 等的動態顯示

讓 user 不致以為沒有在運作

 

如果你有仔細看圖片 可以發現 這些資料是 scrollable 的

就像 Excel 凍結視窗一樣

而且在一個 browser 的可是範圍內就可以將所有的資料展現出來

不會破壞掉畫面的結構

 

關於 scrollable table 的作法 下次再介紹囉!!

Ajax 完成 AutoComplete

Ajax 真的令人著迷

 

為了方便使用者的輸入, 提供了類似 Google Suggest & Gmail/Yahoo Mail 所提供的功能

讓使用者輸入一個字及可帶出相關的選項供選擇

 

其做法也是在 Page 中定義一個 <div> Tag 來供 XHttpRequest 將回傳的 responseText

加入其 innerHTML 屬性中, 再透過 Javascript 與 DOM 的操作來控制該 <div> Tag 顯示的位置

 

後端要注意的是, 輸出的 HTML (目前我還是習慣用 HTML 的方式輸出, 因為 XML 還需搭配 XSLT 來呈現

還沒學到那邊), 要能與原先的 Page 互動. (可以在主 Page 上 define 一個 JS Function 供呼叫)

 

程式片段:

 

CSS 與 DIV





 

 <style type="text/css">
 DIV{
  scrollbar-DarkShadow-Color:#9FB7D7;
  scrollbar-Track-Color:#F7F7F7;
  scrollbar-Face-Color:#C7CFFF;
  scrollbar-Shadow-Color:#FFFFFF;
  scrollbar-Highlight-Color:#FFFFFF;
  scrollbar-3dLight-Color:#C7CFF7;
  scrollbar-Arrow-Color:#4F5F87;
 }
 .autocomplete {
  background:#E0E0E0;
  position: absolute;
  border: solid 1px;
  overflow-y:scroll;
  overflow-x:auto;
  height:100px;
  display: none;
 }

</style> 
<div id="autocomplete" class="autocomplete"></div>

 

 

Script






 <script type="text/javascript">
  var oauto=new AjaxService();
  oauto.callback=autoCompleteResponse;  


  
  function autoCompleteField(cust_code) {
   event.cancelBubble=true;
    var key=window.event.keyCode;
   switch (key){
     case 9,13,27: // Tab, Enter, Esc 鍵
      return;
   }
  
   var querystring="cust_code="+encodeURI(cust_code);
   var url = "/Authority/autoComplete.jsp?"+querystring;
   oauto.loadXMLDoc(url);
   return false;
  }
   
  function autoCompleteResponse() {
   // only if req shows "loaded"
   if (oauto.xhttp.readyState == 4) {
    // only if "OK"
    if (oauto.xhttp.status == 200) {            
     $('autocomplete').innerHTML = oauto.xhttp.responseText;
     $('autocomplete').style.display="block";
     $('autocomplete').style.width=$('cust_code').offsetWidth;
     var point = fGetXY($('cust_code'));
     $('autocomplete').style.top=point.y+$('cust_code').offsetHeight+15;
     $('autocomplete').style.left=point.x+10;
    } else {
     alert(errormsg + oauto.xhttp.statusText);
    }
   }
  }    


  function Point(iX, iY){
   this.x = iX;
   this.y = iY;
  }  
  
  function fGetXY(aTag){
   var oTmp = aTag;
   var pt = new Point(0,0);
   do {
    pt.x += oTmp.offsetLeft;
    pt.y += oTmp.offsetTop;
    oTmp = oTmp.offsetParent;
   } while(oTmp.tagName!="BODY");
   return pt;
  }  
  
  function ChangeSelect(){
   event.cancelBubble=true;
    var key=window.event.keyCode;
   switch (key){
     case 9,13,27: // Tab, Enter, Esc 鍵
      $('autocomplete').style.display="none";
   }
  }
  
  function setValue(v){
    $('cust_code').value=v;
   $('autocomplete').style.display="none";
   query(1,v);
  }
 </script>


控制項






<input autocomplete="off" type="text" name="cust_code" id="cust_code" size="20" onkeyup="if (frmQuery.chkAutoComplete.checked) autoCompleteField(this.value);" onkeydown="return ChangeSelect();" /> <input type="checkbox" value="1" name="chkAutoComplete" checked="checked" />啟用自動完成


 


在控制項的 onkeyup event 中去呼叫 autoCompleteField() 與後端 autoComplete.jsp 進行 Ajax 互動


encodeURI 是為了中文碼(雙位元碼)在 XMLHTTP 傳輸中 Unicode 轉換問題


在後端的 jsp 程式需使用






String cust_code=new String(request.getParameter("cust_code").getBytes("ISO-8859-1"),"UTF8");


來讀取 QueryString 中傳遞的參數.


主頁面編碼設為






<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


這樣就不會有編碼的問題


後端 jsp 輸出






while (rs.next()){
  out.print("<a href='#' onclick='setValue(\""+rs.getString("occ01").trim()+"\")' style='cursor:default'>"+rs.getString("occ01").trim()+" ("+rs.getString("occ02").trim()+")</a><br />");
}


透過呼叫主頁面 setValue() 將選取的值回存至控制項中, 即大功告成. :)


可以將 script 的部份 define 成 .js 並修改參數的傳遞 及可當作 library 來使用囉.

我的第一個 Ajax 系統

終於練功練成

 

我的第一支以 Ajax 方式寫的程式可以上線了!!

 

透過 XMLHttpRequest 這個好幫手 (Firefox 內建物件, IE 則要透過 ActiveXObject("Microsoft.XMLHTTP"))

就可以以非同步的方式去將後端查到的資料 Show 在使用者查詢的文件上

並且透過 Cache 的機制, 可以快速的與後端進行溝通

 

Ajax(Asynchronous JavaScript+CSS+DOM+XMLHttpRequest) 不是一項新的技術, 而是一種 Web 2.0 時代的新的開發方式, 由 Jesse James Garrett 於 2005 年2 月所提出的一個新的名詞.

 

如果您使用過 Google Suggests 或 Google Maps, 您一定對於網頁可以這樣使用的方式眼睛為之一亮.

 

根據 Jesse 的定義

 

Ajax isn’t a technology. It’s really several technologies, each flourishing in its own right, coming together in powerful new ways. Ajax incorporates:


·               standards-based presentation using XHTML and CSS;


·               dynamic display and interaction using the Document Object Model;


·               data interchange and manipulation using XML and XSLT;


·               asynchronous data retrieval using XMLHttpRequest;


·               and JavaScript binding everything together.


 


XHTML 是以 XML 的撰寫方式來編寫 HTML 網頁(也就是 Tag 的寫法要求比較嚴謹)

CSS 是美化網頁所不可或缺的東西

DOM(Document Object Model) 則是 Browser 解析網頁的物件模型, 也就是 DHTML(Dynamic HTML)的核心

新的東西只有 XMLHttpRequest 這一個物件, 伴隨 IE 5.x 之後所提供的一個物件呼叫模式(其實就是 Microsoft.XMLHTTP 這個 Dll), Firefox 則是內建在 Browser 物件中

所有上述的東西, 最後透過 Javascript 把它組合在一起

讓你瀏覽網頁時, 不再需要不斷的 refresh 以取得最新的資料, 而是類似 Windows Application 一般以一個畫面就可以完成所有的事.

 

Gmail 就是一個很好的例子.

 

我的第一支程式就是讓 Sales 能夠查詢客戶的信用評等資料, 以判斷是否爭取客戶的信用額度.

公司的徵信人員定期將上市/櫃公司的財報資料鍵入後端系統

業務人員在網頁上輸入客戶代號/客戶名稱, 即可取得各季的徵信資訊

 

在網頁瀏覽上, 完全沒有 refresh 的動作

只有一個簡單的輸入欄位與查詢按鈕

 

使用者按下查詢鈕後, XMLHttpRequest 去 request 相對應的 JSP 程式, 透過後端 JSP 分頁技術將資料處理好時, 會將資料以 XML Data Stream 的方式傳回前端(此動作是背景處理, 使用者感覺不出來)

 

前端透過 DOM 將資料展示在所設定的位置, 並且將資料 Cache

 

這樣使用者就可以很快速的更新資料(幾乎沒有停頓)

 

原始碼

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> 
  <meta http-equiv="Content-Type" content="text/html; charset=big5" />
  <meta http-equiv="Content-Language" content="zh-tw" />
  <script type="text/javascript" src="/js/util.js"></script>
  <script type="text/javascript" src="/js/AjaxService.js"></script> 

  <title>公司信用評等查詢系統</title>
 
  <script type="text/javascript">
    var ajaxobj=new AjaxService();

 function query(page,cust_code) {
  // This demo uses simple Html/JS only, so we load a static html page
        $('result').innerHTML="載入中...";
  var url = "/Authority/auth_all.jsp?page="+page;
  var url1 = "/Authority/auth_cust.jsp?cust_code="+cust_code;
  //var callback = processAjaxResponse;
     ajaxobj.executeXhr((cust_code=="") ? url : url1);   
 }
  </script>
 </head>
 <link rel="stylesheet" href="/css/styles.css" type="text/css">
 <body>
 <form name="frmQuery" method="post">
 <table width="100%" border="0" cellspacing="2" cellpadding="2" style="border: solid 1px; padding-left:10px;">
  <tr>
    <td>請輸入客戶代碼/客戶簡稱</td>
    <td><input type="text" name="cust_code" size="20" /></td>
    <td><input type="button" value="查詢" onclick="query(1,frmQuery.cust_code.value)" /></td> 
  </tr>
</table>
</form>
<p>
   <div id="result">
   </div> 
</p>  

 </body>
</html>

 

藍色字 <div id="result"></div> 即是資料顯示的地方