h:selectManyListbox的rerender刷新问题

    技术2026-10-02  5

    两个radio分别控制一块区域,radio A控制的区域里包含了一个selectManyListbox,也就是多选列表,希望点radio B的时候可以局部刷新selectManyListbox内的值,开始的时候百般不行,后来上网翻了下,终于解决了,这里做个记录,

    先看xhtml代码<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><ui:composition xmlns="http://www.w3.org/1999/xhtml"    xmlns:s="http://jboss.com/products/seam/taglib"    xmlns:ui="http://java.sun.com/jsf/facelets"    xmlns:f="http://java.sun.com/jsf/core"    xmlns:h="http://java.sun.com/jsf/html"    xmlns:rich="http://richfaces.org/rich"    xmlns:a="http://richfaces.org/a4j"    template="layout/template.xhtml">

    <ui:define name="body">    <h:form id="schAdvertiser">   

    <div class="query_pannel">     <div class="query_search">       <ul>     <li class="title">     <div id = "test">      <h:selectOneRadio layout="pageDirection" name="seladv"  id="schadv" οnclick="document.getElementById('schAdvertiser:myadv:0').checked=false">          <f:selectItem itemLabel="搜索选择:" itemValue="1"/>         </h:selectOneRadio>                 </div>        </li>      <li>      <h:inputText  value="#{searchAdvertiserHelper.searchQuery}" οnkeydοwn="if (event.keyCode == 13) { #{rich:element('find')}.onclick(); return false; }" styleClass="search-input">      </h:inputText>      <h:commandButton id="find" value="搜索" actionListener="#{searchAdvertiserHelper.searchad}">         </h:commandButton>     </li>       </ul>     </div>    <div id="test1" class="query_result">      <a:outputPanel ajaxRendered="true">(注意)     <h:selectManyListbox id="tags" rendered="true">     <f:selectItems value="#{searchAdvertiserHelper.menuItems}"/>   </h:selectManyListbox>    </a:outputPanel>   </div>       <div class="mylist">       <ul>               <li class="title">                       <h:selectOneRadio layout="pageDirection" id="myadv" name="seladv" >                   <f:selectItem itemLabel="我的列表:" itemValue="0" />       <a:support event="onclick"  reRender="tags"  actionListener="#{searchAdvertiserHelper.clearSchAdv}"  />        </h:selectOneRadio>                       </li>     <li>        <select name="select">          <option value="1">www.sina.com.cn 新浪网</option>           </select>     </li>   </ul>      </div>    <div class="tip_pannel">提示:通过搜索选择或使用已定义的广告主列表    </div>       </div>            </h:form></ui:define></ui:composition>

     

    其实改动也就是加了标明了注意的那行,具体的原因请参考下面的地址

    http://www.emlog.net/fei/?post=45

    最新回复(0)