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

          日歷

          <2012年1月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          2930311234

          搜索

          •  

          最新評論

          japid學習筆記

          Posted on 2012-01-14 15:40 timelyxyz 閱讀(300) 評論(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中渲染多種模板。


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


          網站導航:
           
          主站蜘蛛池模板: 道真| 康平县| 平远县| 朝阳区| 罗平县| 松桃| 祁阳县| 苏尼特左旗| 土默特右旗| 尼勒克县| 长丰县| 镇平县| 汶川县| 阜康市| 永昌县| 澄城县| 石楼县| 西贡区| 个旧市| 延安市| 茌平县| 阿鲁科尔沁旗| 岳西县| 台北市| 得荣县| 柘荣县| 邯郸市| 仲巴县| 涟水县| 巴林左旗| 云龙县| 中阳县| 龙岩市| 镇安县| 任丘市| 汝城县| 新津县| 陇川县| 独山县| 富宁县| 合水县|