• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    JSP/Servlet:JSF相對于Struts的一些優點

    發布: 2008-10-07 11:43 | 作者: 不詳 | 來源: 測試時代采編 | 查看: 366次 | 進入軟件測試論壇討論

    領測軟件測試網


    This is huge. JSF has 6 objects that implement much of the framework's capabilities and you can easily replace those objects by decorating the default implementations. That makes it ridiculously easy, for example, to add your own custom variables to the JSF expression language. It also makes it easy, for example, to plug in your own view handlers, perhaps a view handler that implements Tapestry-like views so you can truly separate components and HTML. In fact, Shale, does both of those things. As if that weren't enough, JSF gives you numerous hooks into the JSF lifecycle to inject your own voodoo. Shale gives you even more. 
    #5: Event Model

    JSF has an event model that lets you react to value changes, actions, and phase changes in the JSF lifecycle. In JSF 1.1, those events are handled entirely on the server, a sore point to be sure, but JSF 2.0 plans on supporting client-side events as well. Stay tuned. 
    #4: Value Bindings

    With Struts, you are responsible for ferrying data from your forms to your model objects. You implement an action with an execute method that takes a form bean as an argument. Then you manually pull data out of that form bean and push it to your model. For every form in your application. Ugh. With JSF, you do this: #{model.property}. That's all. JSF takes care of the rest. 
    #3: Renderers

    Have you ever looked at the source code for Struts tags? They generate HTML directly. JSF component tags, OTOH, don't generate anything; instead, they refer to a component-renderer pair on the server. The component maintains state whereas the renderer is in charge of rendering a view. The point here is that renderers are pluggable: you can replace the default renderers with your own implementations; for example, in my Felix talk at NFJS, I illustrate how to implement a custom label renderer that adds asteriks to labels that represent required fields. You plug in that renderer, and JSF will automatically use it throughout your application. Sweet. 
    #2: Render Kits

    I had a Struts consulting job a few years ago where we had to support both a browser-based interface and radio frequency devices, and it was painful. That task would've been greatly simplified with JSF because you can create your own render kit?a collection of renderers for a particular display technology?and plug it into JSF. 
    #1: Components

    Components are the number one differentiator between Struts and JSF. Like Swing, JSF provides a rich infrastructure for developing components in addition to a standard set of components. That infrastructure makes it relatively easy to create your own components and share them with others. Already, we're seeing custom components popping up all over the place, for example with Oracle's ADF and MyFaces, both of which provide a rich set of components such as JavaScript-powered calendars, trees, etc. Of course, components are only half the story; typically, components delegate rendering to a separate renderer, which provides substantial benefits (see item #3 above). But, as with most things in JSF, you are not forced to adhere to the party line. If you want, you can implement components that render themselves, although if you do so, you will loose the ability to plug a different renderer into your component. 
    Your liver pays dearly now
    For youthful magic moments
    But rock on completely with some brand new components

    rock'n'roll lifestyle
    from motorcade of generosity by Cake
     
    Trackback URL: http://jroller.com/trackback/dgeary/Weblog/top_ten_reasons_to_prefer 

    本人的一些看法:

    JSF和Struts都是杰出的MVC框架,JSF的設計者之一就是Struts的創始人。

    Struts本人使用不多,只在一個project中用到,而且也僅僅是寫了幾個頁面,那個project我主要做的是business layer部分。不過當時做struts時候感覺有時候真的很臃腫,每個有請求提交的頁面都要對應一個actionform,每個actionform對應一個action類,覺得很麻煩。并且使用Struts所寫的Action類和ActionForm類都依賴于Struts的API,不太符合編程優雅性的規則。而在JSF中,ActionForm和Action則被一個BackingBean所取代,該BackingBean是一個POJO(Plain Old Java Object),頁面請求的處理及導航則通過BackingBean中一個簡單方法調用就可完成。 

    記得在某篇文里面提到JSF對ajax的支持性不太好,而據我所知java.net的blueprint早就提出了JSF層面上AJAX解決的三種方案。值得一提的是Apache Myfaces的的sandbox,有興趣的可以去看看示例,鏈接http://www.irian.at/myfaces-sandbox/home.jsf ,給出了一些基于ajax的jsf組件。


    當然,由于JSF目前還算是比較新的框架技術,組件還在不斷擴展和完善中,不過既然它是JEE 5.0的實現標準,我看好它的潛力。Facelets也使得web頁面的模板化更加容易。自從jsf出現以后,struts陣營的不少人轉向了jsf,比如Professional Struts的作者之一Rick Hightower。

    國內不少java程序員對jsf持有抵制態度,畢竟學習一個新的技術框架需要時間,struts已經用了好多年了,用的很熟,干嗎要放棄這個?我想說的是程序員就是生活在不斷的學習中,為什么國外的軟件人能寫程序寫幾十年,而國內30歲之后的軟件人還在寫程序的少之又少。 

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/

    22/2<12

    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備2023014753號-2
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>