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

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

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

    Sealyu

    --- 博客已遷移至: http://www.sealyu.com/blog

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks

    Let's say that when a user clicks on something, perhaps selecting something from a DataTable or DataGrid, you want to call some server side code, and then popup a modal panel which needs to show content based on the new state setup by your server side call. In my case I have a DataGrid showing a number of items, and when a user clicks on an item I want to set the current selected item on a Seam component on the server, and then popup a modal panel to display detailed information about the item, and provide the user some actions within the modal panel.

    Looking at the solution it seems so simple, but for some reason it took me hours of trying different combinations, orders, tags, JavaScripts, etc... before I could get this to work correctly. I had the panel appearing with the old data, or appearing with the old data and then disappearing completely, only to show the so called new data the next time I clicked on an item, or rendering on the page itself below the footer, or not popping up at all, or popping up with null data, or.... So I'm posting it up here for myself and anyone else who runs into issues.

    First, create your modal panel (rich:modalPanel). I do this in a separate .xhtml file, as I will use the same model panel in various pages throughout the site. In your modal-panel.xhtml file (or whatever you choose to name it), start with a <ui:composition> tag, define your RichFaces xml namespace (and any other JSF libs you'll be using), and then setup your <rich:modalPanel>. You need to give the modalPanel a unique id, in this case we'll call it "myModalPanel".

    <rich:modalPanel id="myModalPanel" autosized="true" zindex="2000">

    Inside your modalPanel tag, you need to define an inner div. This is the div which you will be rerendering after the server action is complete. I use tags, as I'm using Seam. Ensure that any references to backing beans or data that you want refreshed are within these div tags. You must give this div a unique id as well, in this case we'll call it "myModalDiv".

    <s:div id="myModalDiv">

    The one limitation that I've run into here, and if you know how to solve this, please let me know, is that the <f:facet> tags for your header text and controls can't be inside this div, and you can't put the div around the whole modalPanel (or it makes the panel disappear when you rerender). As such you can't make anything from the <f:facet>s be updated on rerender. This is preventing me from having the modal panel header displaying the current selected item's name. Not great, but not the end of the world.

    So inside this div you have your dynamic output. I have lots of

    <h:outputText value="#{backingBean.selectedItem.property}" />

    type entries in mine.

    On your actual page where you will be displaying the modal panel from you need to include the modal-panel.xhtml file, I use a:

    <a:include viewId="/modal-panel.xhtml" />

    Then, I have my page, which includes a rich:dataGrid, and inside it has an <a:commandLink> which creates the AJAX clickable item. This commandLink has to call the backend action, display the modal panel, and rerender your div.

     
    <a:commandLink id="showItem" action="#{backingBean.setSelectedItem(item)}"
    oncomplete="Richfaces.showModalPanel('myModalPanel',{width:550, top:200});"
    reRender="myModalDiv">

    Click Here!
    </a:commandLink>
     

    This makes the panel display, and then the new content is rendered in the panel. It seems to work just how I wanted it to. With the minor annoyance of having to use a static modalPanel header.

    posted on 2009-03-05 09:48 seal 閱讀(681) 評論(1)  編輯  收藏 所屬分類: Seam

    評論

    # re: Displaying and Rerendering a RichFaces ModalPanel from a commandLink 2009-06-09 16:04 xx
    Hello,Sealyu
    I have some problems with modalpanel.I have two pages which will call a same modalpanel page.I click button to show modalpanel .then click a specail button on modalpanel, and now ,i need to return somevalue to my mainpage;but i don't how to return ;
      回復  更多評論
      

    主站蜘蛛池模板: 亚洲国产香蕉人人爽成AV片久久 | 亚洲欧美综合精品成人导航| 女人18特级一级毛片免费视频| 国产精品亚洲一区二区三区| 亚洲女久久久噜噜噜熟女| 久久这里只精品热免费99| 亚洲乱码中文字幕小综合| 免费大香伊蕉在人线国产| a级毛片100部免费观看| 亚洲乱码日产精品BD在线观看| 国产婷婷高清在线观看免费| 日韩视频在线观看免费| 亚洲狠狠婷婷综合久久蜜芽| 亚洲中文字幕在线观看| 成人毛片免费观看视频在线 | 7723日本高清完整版免费| 免费无码AV一区二区| 91亚洲国产成人精品下载| 国产成人3p视频免费观看 | 四虎永久在线精品免费影视| 成人性生交大片免费看好| 亚洲一区二区三区写真| 337p日本欧洲亚洲大胆裸体艺术| 久久午夜免费视频| jizz在线免费观看| 亚洲色大成WWW亚洲女子| 亚洲AV综合色区无码一区| 国产成人免费永久播放视频平台| 69视频免费在线观看| 一个人看的在线免费视频| 亚洲免费黄色网址| 亚洲av鲁丝一区二区三区| mm1313亚洲国产精品美女| 人成午夜免费视频在线观看| 日韩精品无码免费专区午夜不卡| 亚洲av永久中文无码精品综合| 亚洲欧洲自拍拍偷综合| 亚洲精品成人片在线观看精品字幕| 又黄又爽一线毛片免费观看| 成人免费午夜无码视频| 69精品免费视频|