zoukankan      html  css  js  c++  java
  • japid学习笔记

    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中渲染多种模板。

  • 相关阅读:
    Atitit.播放系统规划新版本 v4 q18 and 最近版本回顾
    Atitit.播放系统规划新版本 v4 q18 and 最近版本回顾
    atitit.极光消息推送服务器端开发实现推送  jpush v3. 总结o7p
    atitit.极光消息推送服务器端开发实现推送  jpush v3. 总结o7p
    Atitit.文件搜索工具 attilax 总结
    Atitit.文件搜索工具 attilax 总结
    Atitit.软件命名空间  包的命名统计 及命名表(2000个名称) 方案java package
    Atitit.软件命名空间  包的命名统计 及命名表(2000个名称) 方案java package
    Atitit..状态机与词法分析  通用分词器 分词引擎的设计与实现 attilax总结
    Atitit..状态机与词法分析  通用分词器 分词引擎的设计与实现 attilax总结
  • 原文地址:https://www.cnblogs.com/timelyxyz/p/2322420.html
Copyright © 2011-2022 走看看