網頁

2011年12月7日 星期三

wavemaker-grid



grid 是網頁設計上必要的元件,很可惜 wavemaker 中的grid 無法如 extjs 中的friendly 但是對一個內部表單系統 他應該可以滿足大多數對ajax 架構上的需求

基本設定:
   對grid 設定 主要 是 dataSet 的部分決定 相關欄位,官方幾乎都是 使用 liveVariale 換句話說對官方來說 只要從 資料庫帶出相關資訊就可以 使用,但是對企業系統,我們遇到的幾乎要 '不能跳'與同一頁完成所有的事 我還是使用 Type 跟 Variable  進行
  其設定方式 可以看 官網 : 

對api 有的 就不須在此 說明

相關event
  •    grid :
GridClick: function(inSender, evt, selectedItem, rowId, fieldId, rowNode, cellNode){
var myselect = inSender.getCell(inSender.getSelectedIndex(), 'customField'); selectedItem.getData().empid ==>取 empid 的值
}

  •    row:

ComButClick: function(inSender) {
// 如使用 inSender 不如就 直接使用 對datagrid 已經有 的api
var selrow = this.inComGrid.getSelectedIndex();
}


  •    cell   :

CellDblClick: function(inSender, evt, selectedItem, rowId, fieldId, rowNode, cellNode) {
var mydata = selectedItem.getData(); // 僅可抓到 view 的物件
var userid = mydata.attperson;
var filename = mydata.attfilename;
}


格式相關 :
  •  將顏色與致行改變

dojoGrid1NodeFormat: function( inValue, rowId, cellId, cellField, cellObj, rowObj) {             cellObj.customStyles.push("background: #808080;color:yellow;font-size:10pt;");
}

  •  輸入跟輸出轉值: 

Grid1ButtonFormat: function( inValue, rowId, cellId, cellField, cellObj, rowObj){
if (rowObj.node== this.approveformVar.data.currentNode){ return '現有簽核'; }
else{   return inValue;    }
}

  •  放置圖片 

dojoGrid1NodeFormat: function( inValue, rowId, cellId, cellField, cellObj, rowObj){
reutrn '<img src ="resources/images/att.png" height="16">'
}

  •  tooltip 
須於 start 加入:

dojo.require("dijit.Tooltip");
dojo.connect(this.dojoGrid1.dojoObj, "onCellMouseOver",this, 'showTooltip');
dojo.connect(this.dojoGrid1.dojoObj, "onCellMouseOut",this, 'hideTooltip');


製作 showToolTip

showTooltip :function(e) {
var msg;
if (e.rowIndex < 0) { msg = e.cell.name; }
else {
var item = e.grid.getItem(e.rowIndex);
var cellfiled= e.cell.field;//對欄位名進行讀取
if (cellfiled== 'mycomment' || cellfiled== 'mysuggest')
msg = e.grid.store.getValue(item, e.cell.field);  //對欄位值進行讀取
else if (cellfiled== 'customField'){
var myatt = e.grid.store.getValue(item, 'attfilename');
var paper =e.grid.store.getValue(item, 'attpaper');
if (myatt.length >0 || paper.length >0)
msg ='';
if (myatt.length >0)
msg+='附件:'+myatt+'
';
if (paper.length >0)
msg+='紙本:'+paper+'\n';
}
}

if (msg) {
dijit.showTooltip(msg, e.cellNode); //會產生在後面
//dijit.showTooltip(msg, e.cellNode, ["below", "above", "after", "before"]);
}

}

  製作 hideTooltip

hideTooltip : function(e) {
dijit.hideTooltip(e.cellNode);
}

    特殊需求:
    • 動態隱藏欄位:

      this.dojoGrid1.dojoObj.layout.setColumnVisibility(8, false);


      • 雙擊下載檔案:

      基本上建議 使用 flashUpload , 並製作 download (String page name) 的功能
      在 ServiceeVariable 中 勾選 download ,所以於設定 update  時 系統會自動 帶入
      但 如裝在 Window2003 可能會有 亂碼問題 ,所以 必須進行 檔案名稱轉型 其程式
      如下: 

      returnname = new String(returnname.getBytes("big5"), "ISO-8859-1");



      相關連結 :
      •    wavemaker
      datagrid
      •    dojo 
      dojox.grid. dataGrid
      tooltip










      2011年11月6日 星期日

      (宇宏)Talend工具說明

      對裕隆汽車經銷商 做 的半小時說明主要對工具 與 資料庫運用的說明  
      (宇宏)Talend工具說明
      View more presentations from Sonny Chen

      2011年9月3日 星期六

      waveMaker- 基礎javasctript架構-物件variable(1)

      wavemaker 在資料、畫面傳遞上使用variable 來設計相關函數,因此搞懂 variable 是對資料運用上相當重要的其架構如下
       ================================================
      wm.Variable 父項目為 wm.Component
      wm.Service父項目為 wm.Component

      wm.JavaService 父項目為 wm.ServerComponent
      wm.WebService"父項目為 wm.JavaService

      wm.ServiceInput"父項目為 wm.Variable
      wm.LiveVariable" 父項目為wm.ServiceVariable
      wm.ServiceVariable 包含 [wm.Variable, wm.ServiceCall]


      wm.JsonRpcService父項目為 wm.Service
      wm.FunctionService"父項目 wm.Service
      wm.NavigationService父項目為 wm.Service
      ==================================================
      wm 提供多樣的javascript 結構基本上跟java 類似 所以要了解 wm  可由class 架構中取得
      其中  wm.Object 提供所有物間之 源頭 ,wm.Component 提供基本connect 與plug-in 機制
      以下為基本
      ==================================================
      wm.Object:提供物件value 與 prop 的設定
      toString() ==>return物件型態
      getProp: function(inPropertyName)  ==> 讀取屬性
      setProp: function(inProp, inValue)
      getValue: function(inName)
      setValue: function(inName, inValue)
      ===================================================
      wm.Component :提供 如dojo.connect 機制
      connect()
      connectOnce(sourceObj, sourceMethod, targetObj, targetMethod)
      connectEvents (inObject, inEvents)
      disconnectEvent(inEvent)
      subscribe()
      unsubscribe(subname)
      valueChanged (inProp, inValue)
      createComponent((inName, inType, inProps, inEvents, inChildren, inOwner)
      makeEvents(inEvents, inComponent)
      readComponents(inComponents)
      startTimerWithName(timerName, componentName)
      stopTimerWithName: function(timerName, componentName)
      startTimer: function(timerName)
      stopTimer: function(timerName, addToComponentLog)
      subtractTimerWithName: function(timerName, componentName,time)
      ===============================================
      wm.Service可執行姓並可拿到 result 的物件

       getNamesList: function()
      add: function(inService)
      getNamesList: function()
      forEach: function(inFunction)
          clear: function()
      getService: function(inName, hideFromClient)
      onResult: function(inResult)
      onError: function(inError)
          getOperation: function(inOperation)
       result
       error
      getOperationsList
      ==============================================
      wm.Variable : 提供畫面中存取的關鍵
      json
      wmTypesChanged: function()
      setType: function(inType, noNotify)
      typeChanged: function(inType)
      setJson: function(inJson)

       hasList: function()
       listDataProperties: function()
       beginUpdate: function() ==> buffer 操作
      endUpdate: function()
       isUpdating: function()
      clearData: function()
      setData: function(inData)
      getData: function()
      getCount: function()
      getItem: function(inIndex)
      getItemData: function(inIndex)
      setCursor: function(inCursor)
      setNext: function()
      setPrevious: function()
      setFirst: function()
      setLast: function()
      addItem: function(inData, inIndex)
      getItemIndex: function(inVariable)
      dataChanged: function()
       dataValueChanged: function(inProp, inValue)
      valueChanged: function(inProp, inValue)
      setDataSet: function(inDataSet)
          lazyLoadData: function(inPropName, inVariable)
      setLiveView: function(inLiveView)
          getViewType: function()
      getViewFields: function()
      getViewListFields: function()
      ============================
      待續----------

      waveMaker- wm.base.Control

      wm.base.Control 是處理wavemaker 中editor所有之 parent 物件
      其包含[wm.Component, wm.Bounds],並且除一些如widith 、hight 之屬性
       並且包含下列功能


      addWidget( inWidget)
       getParentBox()
      updateBounds()
      boundsResized()
      padBorderMarginChanged()
      isReflowEnabled()
      setFlex(inFlex)
      getScrollMargins()
      listProperties()
      adjustChildProps(inCtor, inProps)
      removeWidget(inWidget)
      setName (inName)
      getUniqueName(inName)
      updateId()
      isAncestorHiddenLayer()
       setDomNode(inDomNode)
      loaded()
      destroy()
      postInit()
      addUserClass(inClass, inNodeName)









      2011年6月4日 星期六

      Java with AS400's Spooled File

      Introduction,
      Jtopen develop the solution for AS400 access, that included System/File and database access. This page shows some successful information for using SpooledFile.
      SpooledFile is AS400  implenets for output file, that including RPG/CL usage.
      Jtopen can using 2 type of access, one is single file, another is using list.

      Single file access, the stage for using

      1. System connection : AS400()
      2. Setup OutputQueue: 
      3. setup  Spooled fille 
      System Connection :
         the stage for conneciton as folow:
      • new AS400 : pass: system user id password.
      • Service : PRINT, FILE
      Setup OutputQueue
      OutputQueue identify output query , the cnstructor is   
      OutputQueue(AS400 system, String queueName)
      as default if the Command does not set any output attribue : queuename could set as /QSYS.LIB/QUSRSYS.LIB/QPRINT.OUTQ

      Setup SpooledFile
      SpooledFile(
      AS400 system,
      String spoolfiename,
      int jobnumber,
      String jobname,
      String jobUser,
      String jobnumber);

            AS400 system,
            String spoolfiename,
            int jobnumber,
            String jobname,
            String jobUser,
            String jobnumber);
      then using
      copy(OutputQueue outputQueue)    
      move(SpooledFile targetSpooledFile)
        to make to java Stream type

      Possible Source as following:





      MutiFileAccess
      Muti-File, in JTopen , recommend use SpooledFileList() then it can access by QueueFileter and Enumeration , read and send output file possible using PrintObjectTransformedInputStream to read .



      Possible Solution :

      In some statement, using FTP can solve the same effect, However, using Command call and read file doing the same time, it should solve some trouble

      Reference:

      JTOpen: http://jt400.sourceforge.net/

      2011年5月6日 星期五

      AS400 上 SYSIBM.COLUMNS 的 View

      最近 在調整 AS400 到 不同資料庫 發覺 有幾隻View 是可以 值得觀察的 首先
       如果 使用 SYSIBM.COLUMNS
      =====================================
      select
           TABLE_SCHEMA,
           TABLE_NAME,
           COLUMN_NAME,
           DATA_TYPE,
           IS_NULLABLE,
           CHARACTER_MAXIMUM_LENGTH,
           NUMERIC_SCALE,
           NUMERIC_PRECISION,
           COLUMN_DEFAULT,
           CHARACTER_SET_NAME   
       from SYSIBM.COLUMNS
       =====================================

      可帶出想要的 create table 所需的資訊,那就可以動 建table 在不同資料庫上啦

      talend 放置資料於globalMap 與 context

      Talend Open Studio對異質整合的功用是一件值得學習的方式,只是tool 本身有太多需要程式定義的方法,如globalMap, context 幾乎是值得研究的地方

      globalMap 的用法
        globalMap 是畫在  Job 所生成的 物件暫純區 所有 有用到的 拖拉元件都會有對應

      如使用 tLoop_1 會產生 一個相關的globalMap 中的
            tLoop_1_CURRENT_VALUE  與 tLoop_1_CURRENT_ITERATION
      其讀取方式  可用  globalMap.get("tLoop_1_CURRENT_VALUE")拿到 相對應的object
      當然 其他有其他的 

      context
      是定義內部暫純區
      如使用於 tJavaFlex 我就可以 放
            context.put("mydates",mydates);
      之後用的地方可以使用此conext.get("mydates") 讀取此物件

      2011年5月1日 星期日

      流程規劃淺見

      流程系統一般都規劃為資訊管理系統的核心,一般所見可分為三個部分
      1. 業務流程(Business Flow)
      2. 系統整合(EIP)
      3. 人事簽核(Human Task)
      現在流程產品大多包含前兩項,並且將簽核部分以串/會簽模式進行規劃,所以在規畫的建議
      大多使用者可了解,但是在運作上,流程的待處理(todo list)又是一項艱鉅的工程更不用提 流程版本,人事異動與流程異動,掉單處理 是現有產品面都有所欠缺的。

      經過多次流程規劃的見解,我還是建議以下方向:
      1. 以主副流程形式規劃
      2. 主流程以業務流程為依歸
      3. 人事簽核建議以Rule Engine 形式進行
      4. 系統規劃建議以同步與非同步為流程異動要素
      5. 系統整合面的需求在實務上要小心資料所屬的問題
      在系統代處理規劃,建議確認方針如下

      • 追蹤還是代辦
      • 逾時通知(上班日與否)
      • 系統異常通知
      至於人事異動那就要配合規劃上是否需要對流程版本需控管,有時候未完成項目跑舊流程但須新人事,有時又要舊版本舊人事。

      2011年4月7日 星期四

      AS400 SQL 錯誤 對照 與 解籤法(廟公說有成功的)

      SQL0551   ==> 

           權限問題

      1. 使用者沒權限  一般都是 journal的問題 (建議 不要用jounnal 管控除非你很懂 AS400 的管理)

      SQL 0104   ==>

            欄位tokern 的問題(SQL 語法 寫錯 要先檢查 是不是 自己的問題會 show 在 error log 上)

        1.  如使用新增table(create table) 中有 varchar 型態 檢查 是否為大寫 (改為 VARCHAR) 

        2. 查詢指令 檢查 是不是 ", " 沒加 (select 指令有問題)  


           

      SQL0913N ==>

      死鎖或逾時

      1. 需要將 使用者剃除 好像沒有sql 的解法 需要用 AS400 Client Access 

        SQL0952==>

        試過

        alter table <table> alter column <col> set data type numberic(8,2)

        因 alter 只有 varchar 可以ok 其他 會有問題

         

         


       


      db2 Function - timestamp 問題

      一直以來 db2 可使用的 內建 function 真的 有些奇怪
      在 版本 9.5 可以 run 的 在 9.1 有時 真的 需要保佑 ,
      其中 對 TimeStamp 的 運行 會有不是一般人可理解的地方
      下方funcion 是多次運用的紀錄:


      COALESCE: 
      主要是將 NULL 轉成其他 所以 類似於oracle 的NVL 內容

      發生錯誤的 SQL CODE=180
             COALESCE(欄位值, '')   是不會成功的
      要修正成
              COALESCE( 欄位值,'1000-01-01-00.00.00.000000')
      其中 第二個是需要 timestamp 格式才可以

      CHAR
      將值變成想要的格式 但是 跟to_char 不同
      用法 如
          CHAR(col, fomat)
      fomat 可用的
      date 
       ISO:     ==>2005-12-31
      USA:     ==>12/31/2005
      EUR     ==>31.12.2005
      JIS       ==>2005-11-30
      LOCAL   ==> 看你的 設定
      time

       ISO:     ==>19.42.21
      USA:     ==>19:42:21

      EUR     ==>19.42.21
      JIS       ==>19.42.21
      LOCAL   ==> 看你的 設定
      timestamp
      抱歉 只能用  ISO
      char(current timestamp) ==> 2005-11-30-19.42.21.873002

      VARCHAR_FORMAT or TO_CHAR
      (9.1 to_char 會work 9.5 varchar_format 比較理想)
      就是 oracle 中的 to_char 只是 比較好玩 
         TO_CHAR(col,fomat)
      其中 fomat
      有試過
      'YYYY-MM-DD HH24:MI:SS'
      "YYYY-MM-DD HH:MM:SS"

      ,VARCHAR_FORMAT(ts1,'YYYY-MM-DD HH24:MI:SS')

      TO_DATE (string_expression_r_r, 'YYY-MM-DD HH24:MI:SS')

      2011年4月6日 星期三

      簡單的 網路阻擋器Port Blocker

      最近有個客戶(學校科室) 要一個簡單但對網路安全設定工具,因為學校是一個半開放式的環境因為學校的所有IP 是互通的 ,科室系統是一個 Client-Server 軟體 換句話說只要有學生知道它們的IP, Server 就有被攻擊的危險,基於上列需求 我開始 對google 大神 進行膜拜,本來我以為找個 FireWall 就可以交差,但是 找半天,我發覺可能這種東西不值得做,大家都希望包含 病毒掃瞄 或 更高層的硬體與狀態監控 。換句話說 做得好複雜。

      綜觀上列問題,我要找的軟體須包含
      1. 簡單設定(因為老師們 是 僅有使用知識 但沒有IT 知識)。
      2. 要獨立於window(因為老師說那個太基本)
      3. 須可以 對單一IP 進行開放
      4. 需可對單一Port進行阻擋。
      5. 操作需要很簡單(最多三部完成設定)
      找半天後 我推薦 Emsa Port Blocker
      其資訊如下
      當你download 完後 就可以 啟動
      可點選 Get Free Action....
      並且會打開Browser.









      點選 Port Blocker
        點選 Activate product here



      這個時候你就可拿到 code : 如下圖

       設定順序:
      1. Blocked Local Ports



      2. Allowed IP Address

      設定完成 。

      2011年3月19日 星期六

      整合工具 -Talend

      Talend 他是一套系統整合用的工具,在專案的運用上不管是資料庫,檔案,系統連結
      有其高竿的元件使用

      他的 License 一般都是 Apache License 所以 不太需要 有其他的 Payment 只要學與用
      減少很多在 資料整合與 訊息交換上的 一堆麻煩。

      它存在 java 與 perl 的程式產生器 所以 只要懂Java 與 eclipse 上手還算簡單,
      在 資料庫 建置上 我建議 下列 步驟
      1. 建立連結
      2. 建立 metadata
      3. 建置 Job
        1.  
      在檔案整合上建議下列步驟
      1. 建置metadata
      2. 建置Job
        <有空再寫>

        AS400 跟Java - 基本資料

        DB2 跟 AS400 是都是在偉大的 Blue Company所創造的系統,他的可用度與其設定法則
        有跟一般開放系統又不一致,所以在限定的範圍與多樣需求的現實需求上,IBM產生出
        一些它特有的方式,並且配合開放的Java 使用 產生出不一樣的做法,在經過專案的歷練下後整理出下列項目,
        1. AS400 與 資料庫 對照
        2. 系統連結設定
        3. SQL Function
        4. CCSID 的轉換
         AS400 與 資料庫 對照
         在 AS400 跟資料庫 的名詞對照 如下
              

              Table   = Physical file
              View =Non-keyed logical file
             Index Keyed= logical file
             Column =Field
            Row=Record
            Schema Library=  collection
            Log=  Journal
            Isolation level Commitment = control level



        系統連結設定
            1. Driver:
                一般系統連結在JDBC 的規範 可使用 Jtopen 其網址(http://jt400.sourceforge.net/)一般使用的規範須以下列格式
                  需使用 的 jar: jt400.jar
                  The class name to register is com.ibm.as400.access.AS400JDBCDriver
                  URL : jdbc:as400://ip;name1=value1;name2=value2;...
           2. URL 的設定參數
                設定參數 將決定  AS400 的型態 並且在連結上的特性 其中包含幾個項目: 
              (根據 http://www.i5tools-eu-download.net/reference/jtopen/6.6/com/ibm/as400/access/doc-files/JDBCProperties.html)
        設定 有使用
        ;libraries=cshr1;prompt=false;char.encoding=UTF-8
        但是 在連結 CCSID =65535 的欄位 需要將該欄位 進行調整
        如設為 ccsid =937 有時候 會解決此問題
        ccsid=<ccsid code>
        convert _ccsid_65535=yes|no
        一般
        prompt 
        database name"    *SYSBAS
        libraries *LIBL
        package ccsid     dafault ==> 13488(UTF16)
        translate hex  =false  一般僅在使用 binary 型態的欄位使用
        欄位設定
        date format  ==>
        date separator
        decimal separator
        naming   ==> sql ==> schema.table  system==> schema/table
        time format
        time separator
        ccsid=<ccsid code> and convert _ccsid_65535=yes|no

        bidi string type  ==>http://www.i5tools-eu-download.net/reference/jtopen/6.6/com/ibm/as400/access/BidiStringType.html#navbar_top

        translate binary  ==> BINARY and VARBINARY fields to char and varchar

        SQL Function

        日期相關
        Function Description
        CURDATE()
        CURTIME()
        Returns the system's current date/time.
        DATE(D)
        DATE(T)
        Converts a string representation of a date/time into into a
        date/time value.
        DAY(D) Returns the day(1-31) from the date D.
        WEEK(D) Returns the week (1-54) from the date D.
        MONTH(D) Returns the month (1-12) from the date D.
        YEAR(D) Returns the year from the date D.
        DAYOFWEEK(D) Returns the week day (1-7) from the date D where 1 is Sunday.
        DAYOFWEEK_ISO(D) Returns the week day (1-7) from the date D where 1 is Monday.
        DAYOFYEAR(D) Returns the number of the day, in a year (1-366).
        HOUR(T) Returns the hour (0-24) from the time T.
        MINUTE(T) Returns the minute from the time T.
        SECOND(T) Returns the second from the time T.
        MICROSECOND(T) Returns the microsecond from the time


          
        String 相關
        CHAR(N) Returns the the string representation of the
        number N.
        CHAR_LENGTH(S) Returns the length of a string.
        CONCAT(S1, S2) Concatenates S1 with S2.
        SUBSTR(S, I, L) Returns a substring of S, starting at index I of lenght L.
        LOWER(S) Returns the lowercase representation of S.
        UPPER(S) Returns the uppercase representation of S.
        TRIM(S) Removes spaces from the beggining and and of S.
        RTRIM(S)
        LTRIM(S)
        Removes spaces at the begging (right) or end (left) of S.

          
        <未完待續>