posts - 35, comments - 0, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          japid學習筆記

          Posted on 2012-01-14 15:40 timelyxyz 閱讀(298) 評論(0)  編輯  收藏

          1. 控制輸出時間
          <div>
              <p>this part is cached for 10 seconds. Note the timeout spec with invoke overrides CacheFor annotation. </p>
              `a controllers.more.Portlets.panel2(b), "10s"
          </div>
          <p>內文字顯示十秒鐘然后進入panel2action

          2.log:log directives are used to print a line of information to the console. It can take an argument of String
          `log
          `log a + i
          `log "a message "
          log命令用來在控制臺輸出一行信息,后面可以添加參數,輸出結果如下:
          japidviews/templates/log.html(line 5):
          japidviews/templates/log.html(line 14): a10
          japidviews/templates/log.html(line 18): a message

          3.stopwatch m 輸出render到模板所需的時間

          4.~i  直接輸出i的值

          5.`each posts | String p 與`for String p : posts等價,
          `for String p : posts
              <p>index: $_index, parity: $_parity, is odd? $_isOdd, is first? $_isFirst, is last? $_isLast, total size: $_size </p>
              call a tag:  `tag SampleTag p
          `
          輸出index: 6, parity: even, is odd? false, is first? false, is last? true, total size: 6
          另一種格式
          `for (final Post p : posts) {
              another notation for invoking actions:  
              `invoke Application.echoPost(p)
          `}

          6.if-else循環語法:
              `if expr            `if(asBoolean(expr)){
                  xxx                xxx    
              `else if expr        `} else if(asBoolean(expr)){
                  yyy                yyy
              `else            `} else {
                  zzz                zzz
              `            `

          7.` suppressNull on如果下面出現了null的意外,如
          ` a = null;
          safe to do a.something too: $a.length()
          輸出safe to do a.something too:

          8.dontRedirect();控制不跳轉頁面,即停留在原頁面。

          說明:

          ∵在play運行時,調用一個action必須出發一個Http重定向

          ∴如果不想重定向,必須調用JapidController.dontRedirect()來避免

          9.${a}, ~a, $a and ${escape(a)} and ~{a}這幾種表達式的值相等

          10.頁面讀取異常
              `for (Error e: errors()){
                  <p>$e.getKey() : $e</p>
              `}

          11.“Elvis操作符”是Java三目運算符的簡寫。一個便捷的用法是,如果表達式的值為false或者null,則返回一個合乎情理的默認值。好吧,我所實現的Elvis操作符確實不像Java中的一樣:)我所添加的?:組合符號只在${}標簽內起作用。
          name ?: “empty”

          12.`doBody m:帶著參數回到原先界面。該命令中的參數列表必須與調用處的“|”之后的參數聲明匹配,doBody通過匹配的參數傳遞到模板。

          13.join(Strings, "|"):Strings是list,該方法為list中的每個元素見添加一個“|”,形成一個字符串。

          14.`invoke與`a觸發的action返回的結果直接插入到原先界面中,作為界面參數的一部分。注意:invoke出發的action不跳轉頁面。

          15.renderJapid(Object... Objects):帶著參數跳轉到原先界面

          16.renderJapidWith(String template, Object... args):帶著參數跳轉到指定模板,可以實現在一個action中渲染多種模板。


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 宜都市| 仙桃市| 哈巴河县| 宣城市| 互助| 阳山县| 河北区| 湖北省| 甘孜| 彰武县| 湘乡市| 静宁县| 喀喇沁旗| 萍乡市| 永修县| 商河县| 乐陵市| 廉江市| 舞阳县| 安远县| 常德市| 东山县| 福海县| 铜川市| 广元市| 金山区| 思茅市| 辽阳市| 平塘县| 婺源县| 蒲城县| 阳高县| 垫江县| 莎车县| 长治市| 通化市| 泉州市| 莒南县| 信宜市| 阆中市| 名山县|