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

          日歷

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

          搜索

          •  

          最新評論

          japid學(xué)習(xí)筆記

          Posted on 2012-01-14 15:40 timelyxyz 閱讀(299) 評論(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>內(nèi)文字顯示十秒鐘然后進(jìn)入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命令用來在控制臺輸出一行信息,后面可以添加參數(shù),輸出結(jié)果如下:
          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循環(huán)語法:
              `if expr            `if(asBoolean(expr)){
                  xxx                xxx    
              `else if expr        `} else if(asBoolean(expr)){
                  yyy                yyy
              `else            `} else {
                  zzz                zzz
              `            `

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

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

          說明:

          ∵在play運行時,調(diào)用一個action必須出發(fā)一個Http重定向

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

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

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

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

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

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

          14.`invoke與`a觸發(fā)的action返回的結(jié)果直接插入到原先界面中,作為界面參數(shù)的一部分。注意:invoke出發(fā)的action不跳轉(zhuǎn)頁面。

          15.renderJapid(Object... Objects):帶著參數(shù)跳轉(zhuǎn)到原先界面

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


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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 商南县| 太原市| 类乌齐县| 黔南| 苍梧县| 大港区| 汝城县| 临洮县| 辰溪县| 普定县| 茌平县| 三穗县| 敦化市| 上思县| 金寨县| 都江堰市| 澄迈县| 伊宁县| 定襄县| 扬中市| 肇州县| 汪清县| 山东| 河津市| 平谷区| 武山县| 景东| 永靖县| 怀化市| 巴林右旗| 边坝县| 夏邑县| 湖口县| 同仁县| 来凤县| 淮北市| 鄱阳县| 保定市| 罗源县| 格尔木市| 高淳县|