2011-04-12 121 views
0

請看下面的代碼片段:RichFaces Ajax(條件)渲染:HowTo?

<h:form> 
    <h:panelGrid columns="2"> 
     <h:inputText value="#{vehicleBean.pin}" /> 
     <a4j:commandButton action="#{vehicleBean.loadVehiclesByPin}" render="results"/> 
    </h:panelGrid> 
</h:form> 
<a4j:outputPanel id="results"> 
    <rich:dataTable value="#{vehicleBean.vehicles}" rendered="#{not empty vehicleBean.vehicles}"> 
     ... 
    </rich:dataTable> 
</a4j:outputPanel> 

當我按下按鈕一個Ajax請求被髮送到加載一些經營實體。 它們顯示在rich:dataTable中,只有在相應的數組不爲空時纔會顯示。

這適用於Chrome中的Firefox 4,但不適用於IE9。 但我敢肯定它是我的錯,而不是IE的;-)

所以,請告訴我:

  • 什麼是解決這類問題的正確途徑(與有條件渲染元素)?
  • 我應該重新渲染哪個元素?
  • commandButton也有一個execute屬性:何時以及爲什麼我必須使用此屬性?

問候塞比

回答

0

的RichFaces 3.x中不支持IE9,請參閱這篇文章: http://community.jboss.org/thread/156720

您可以升級到RF 4, 或實現一個過濾器,迫使IE9運行中兼容模式:

public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { 
    HttpServletResponse resp = (HttpServletResponse) response; 
    resp.addHeader("X-UA-Compatible", "IE=EmulateIE8"); 
    chain.doFilter(request, resp); 
} 
0

一些東西,你能解決:

  1. 讓你的表單標籤環繞的所有JSF compontents
  2. 如果loadVehiclesByPin依靠腳的價值,你應該執行inputText組件(分配一個ID,它,例如「inputPin」)用的commandButton這樣的:執行=「@這個inputPin
  3. 我不知道,如果你使用了正確的在渲染=「結果」(知曉NamespaceContainer概念,閱讀的的javadoc UIComponent.findComponent

更好的調試,我建議讓PROJECT_STAGE =發展web.xml和打開你的瀏覽器的JavaScript控制檯。

注意的是,使用條件呈現時,您需要點渲染參數在JSF組件樹的ID,即已經存在(你沒有在這裏通過圍繞你用面板有條件的dataTable)

關於