<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Vikings

    TapeStry 4.0 beta 新特性 1-3

    [原文]
    http://spaces.msn.com/members/jface/PersonalSpace.aspx?_c01_blogpart=blogmgmt&_c=blogpart

    Tapestry4新特性(一)-default binding types

    一、default binding types(默認的綁定類型)
        每一個組件的參數都可以定義默認的綁定類型,如果一個綁定的參數沒有前綴,將使用默認的綁定類型。
        下面的代碼實現同樣的功能:

       

         加粗的部分顯示前后的變化,之所以可以這樣定義,是因為Insert組件定義value參數的默認綁定類型為ongl.
         注意:默認的綁定參數總是可以被顯式的綁定聲明覆蓋掉。
        如果沒有定義默認的綁定參數,那么在html模板中定義的默認綁定參數為literal,頁面定義文件里的默認綁定參數為ognl

    修訂:

    從beta4版本開始,此特性已經被刪除,

    Beta4的change log:

     Remove default-binding attribute from element(HLS)

    但是“如果沒有定義默認的綁定參數,那么在html模板中定義的默認綁定參數為literal,頁面定義文件里的默認綁定參數為ognl”這個效果經測試依然存在。

    懷念:

    此段文字在beta3中存在,beta4后就刪掉了!

    Binding Type Defaults

    Tapestry 4.0 introduces a new idea: default binding types. Each component parameter may define a default binding type (using the default-binding attribute of the element).

    If a binding reference does not have a prefix, the default binding type is used.

    Because of this, the following two snippets are identical:

    This works because the Insert component defines the default-binding for the value parameter to be "ognl". Likewise, the source and value parameters of the Foreach component are defined to be "ognl". However, the element parameter of the Foreach component has a binding type of "literal".

    This is a decision made by the component author. If a particular parameter is (nearly) always bound using a particular binding type, then a default-binding may be set. The default binding can always be overriden with an explicit binding type prefix.

    What about parameters that don't define a default binding type? The answer to this question (which includes all informal parameters), is that it depends on whether the parameter is bound in an HTML template, or in a page or component specification. In an HTML template, the default binding type is "literal". In a specification, the default binding type is "ognl".



    Tapestry4新特性(二)-listener method
    二、listener method
         如果使用過tapestry的應該知道listener方法在4.X以前版本中的定義,如public void formSubmit(IRequestCycle cycle),方法必須
    有一個IRequestCycle參數。參數的取得方式如下:Object[] parameters = cycle.getServiceParameters();
         在4.X中參數的取得可以通過以下兩種方式:
    1. 調用IRequestCycle.getListenerParameters()方法,需要傳入IRequestCycle實例作為參數。
    2. 按照參數的聲明順序依次定義為listener方法的參數。

         第二種方法比較符合軟件的設計思維,而且參數的類型在傳入后保存,而不是想象中的統一String類型。
    例如:
    . . .
    其中objectId為String類型,index為int,聲明中使用了默認的參數綁定類型。
    對應的方法聲明如下
    public void doClick(String objectId, int index)
    { . . . }
    此為第二種方式,可見方法的定義符合自然習慣,當然你也可以通過傳統的方法,如下所示: public void doClick(IRequestCycle cycle)
    { Object[] parameters = cycle.getListenerParameters();
    String objectId = (String)parameters[0];
    int index = ((Integer)parameters[1]).intValue(); . . . } 
    這種方式是為了向后兼容以前的版本,當然也適用那種參數數目不確定的情況。 Tapestry默認搜索以下的方法聲明:

    • public void method(parameters)(頁面的跳轉 cycle.activate()如何實現?)
    • public void method(IRequestCycle cycle, parameters) (傾向于使用此方式)
    • public void method()(無需參數傳遞和頁面跳轉的情況,估計可能性不大)
    • public void method(IRequestCycle cycle)(傳統方式)
       不要試圖通過參數的類型來映射listener方法,tapestry是根據參數的數目來確定方法的。

    Tapestry4新特性(三)-global property source
    三、Global Property Source(全局的消息屬性配置)
    消息屬性配置聽起來不是很舒服,暫時這樣稱呼好了,消息屬性配置也就是通稱的國際化配
    置,通過配置一個properties文件使不同語言的瀏覽者看到對應語言的版本,一般
    的使用如下,一個page頁面,例如example.page,同目錄下放一個
    example.properties,在 example.html中使用來指定顯示值,
    中文可以使用example_zh_CN.properties來配置。看起來挺方便的,可
    tapestry4.0以前的版本的國際化不支持全局的屬性配置文件,必須每個頁面定義
    自己的,無法幾個頁面共享,但實際開發中,多頁面共享屬性配置是很常見的,
    tapestry4.0中可以通過以下方式獲得全局的屬性配置文件:
    創建一個跟你的項目全局配置文件,如yourApp.application,此文件在4.0以前的
    版本中是必須的,4.0中如果沒有必要配置,可以不需要此文件(扯遠了),yourApp
    是根據你在web.xml定義的,例如

    tapesty4
    org.apache.tapestry.ApplicationServlet
    1

    那屬性定義文件就應該是tapestry4.properties,這樣在此文件中定義一個:test=
    測試,在Home.html中使用< span key="test">test
    ,看到“測試”正確顯示。

    posted on 2005-11-08 17:55 Vikings 閱讀(352) 評論(0)  編輯  收藏 所屬分類: frame-work

    主站蜘蛛池模板: 亚洲自偷精品视频自拍| 成人亚洲性情网站WWW在线观看| 久久精品国产亚洲夜色AV网站| 无码毛片一区二区三区视频免费播放 | 在线播放免费播放av片| 亚洲成AV人综合在线观看| 2022久久国产精品免费热麻豆| 亚洲精品福利网站| 国产va精品免费观看| 亚洲av永久中文无码精品综合 | 亚洲色偷偷色噜噜狠狠99| 最近免费中文字幕大全视频| 亚洲日韩国产一区二区三区在线 | 久久久久亚洲AV片无码| 国产l精品国产亚洲区在线观看| 亚洲精品欧洲精品| 成人免费一级毛片在线播放视频| 久久亚洲国产最新网站| 国产色爽免费视频| 亚洲国产精品一区二区久| 国产香蕉九九久久精品免费| 亚洲AV综合永久无码精品天堂| 亚洲成片观看四虎永久| a毛看片免费观看视频| 亚洲国产美女福利直播秀一区二区 | 亚洲中文字幕久久精品蜜桃 | 亚洲AV无码不卡在线播放| 久草视频免费在线| 国产亚洲精品xxx| 日韩在线一区二区三区免费视频| 亚洲日本乱码在线观看| 真正全免费视频a毛片| 亚洲自偷自偷偷色无码中文| 99re6在线视频精品免费下载| 亚洲最大的成人网站| 久久久久国产亚洲AV麻豆| 97在线观看永久免费视频| 美女视频黄a视频全免费网站一区 美女视频黄a视频全免费网站色 | 国产精品亚洲二区在线| 亚洲乱码国产乱码精品精| 免费在线看v网址|