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

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

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

    隨筆-112  評論-73  文章-0  trackbacks-0

    在JSF組件開發過程遇到一個問題.就是當自己開發的組件再次提交的時候會提示一個錯誤:

    Duplicate component ID ... found in view.

    意思是說在ViewRoot中已經存在一個同名的組件了.這是JSF不允許的.

    后來在網上苦苦的找....終于找到這個一篇:http://www.jroller.com/mert/entry/duplicate_component_id_found_in 部分原文如下:


    I stated some possible solutions for the exception.

    1. If you are dynamically adding child components to a UIComponent, also set the id of the child components explicitly.

    2. If you are using JSTL tags like forEach, if, choose and when, make sure you specify unique ids for the components defined between these tags at each iteration. For example,

    <c:forEach>
    <theComponent id="componentId + unique value for each iteration" />
    </c:forEach>

    The id for theComponent should be composed with a value that is unique each iteration.

    3. If you are developing a custom JSF Component just define id attribute in .tld file. You don?t need to specify id property in tag class. Because it inherits the id from UIComponentBase. So you should also set the properties of the super class within setProperties() method of the component.

    4. You cannot determine an id like "_idX" manually in your jsp source code, it is not a valid component identifier (cannot start with "_" ) so re-check the previous steps :)

    其中第三條正是我遇到的問題的原因的答案.就是在自己開發的組件中,只需在tld文件中指定id屬性,不需在tag.class中再設置id屬性.具體的是不能再有setId(String id)這樣的方法了.因為父類UIComponentELTag中已存存在這個屬性.而且是在tld中一定要設置成靜態的String類型.不能是ValueExpression類型

    在tld文件中這樣設置id屬性

    <attribute>
    <name>id</name>
    <rtexprvalue>false</rtexprvalue>
    <type>java.lang.String</type>
    </attribute>
    然后把tag class中的id 屬性和setId方法去掉.

    ^_^

    一點感想:

    成功和失敗真的是一步的距離、一時的閃念。在尋找答案的過程中真是想放棄自己開發的這個組件,但另一種信念使我沒有放棄,最后終于解決了。

    用一個小小組件中的一個問題的解決來說成功與失敗也許是小題大做,但這個成功的信念是一樣的。只要堅持就會有結果!


    Technorati :

    posted on 2007-08-18 09:13 Libo 閱讀(2001) 評論(1)  編輯  收藏

    評論:
    # re: JSF組件ID重復的問題 2007-08-18 13:47 | Alex
    自己開發組建? 精神可嘉,不過個人認為沒有太大的實際價值  回復  更多評論
      

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


    網站導航:
     
    主站蜘蛛池模板: 亚洲成a人在线看天堂无码| 免费91麻豆精品国产自产在线观看| 亚洲综合精品第一页| 亚洲国产亚洲片在线观看播放| 亚洲天天在线日亚洲洲精| 亚洲大片在线观看| 亚洲视频一区调教| 亚洲人成黄网在线观看| 国产精品高清视亚洲一区二区| 亚洲中文字幕无码久久2020| 亚洲欧洲无码一区二区三区| 亚洲精品无码久久久久YW| 噜噜综合亚洲AV中文无码| 午夜在线免费视频 | 羞羞视频在线观看免费| 男女猛烈激情xx00免费视频| 男男黄GAY片免费网站WWW| 黄色大片免费网站| 一级特黄录像免费播放肥| 精品国产免费一区二区三区香蕉| 久久久久久免费一区二区三区| 日日麻批免费40分钟无码| 免费在线视频你懂的| 国产精品久久久久久久久久免费| 成人啪精品视频免费网站| 国产精品高清全国免费观看| 亚洲人成影院在线观看| 亚洲国产精品va在线播放| 亚洲色大成网站www永久| 亚洲无人区码一二三码区别图片 | 久久亚洲日韩看片无码| 亚洲mv国产精品mv日本mv| 亚洲αⅴ无码乱码在线观看性色| 色老头综合免费视频| 免费一区二区三区| 精品久久久久成人码免费动漫 | 在线播放高清国语自产拍免费| 五月婷婷亚洲综合| 亚洲AV无码一区东京热| 亚洲av无码专区在线| 美女18毛片免费视频|