2010-11-24 73 views
1

在Seam/RichFaces頁面中是否有可能禁用AJAX,因此請求是通過定期的服務器 - 客戶端請求發送的,整個頁面被刷新而不是單個元素?我正在使用a4j:outputPanela4j:commandButton,並且需要讓他們在某些情況下不通過切換按鈕使用AJAX。是否可以在RichFaces中禁用AJAX?

這是來自頁面的代碼片段。謝謝。

<a4j:outputPanel id="output" rendered="#{not empty overtime.overtimeItems}" 
    ajaxRendered="true"> 
    <c:forEach items="#{overtime.overtimeItems}" var="oc"> 
    <h:outputLabel value="#{oc.dateLabel}" 
     style="font-weight:#{(oc.id == 1) ? 'bold' : 'normal'}" 
     for="#{oc.overtimeDateId}" /> 
    <rich:calendar value="#{oc.overtimeDate}" 
     requiredMessage="Date 1 is required." 
     id="#{oc.overtimeDateId}" datePattern="MM-dd-yyyy" 
     required="#{oc.id == 1 ? true : false}" firstWeekDay="0"> 
     <a4j:support event="onchanged" 
     reRender="#{oc.overtimeHoursId}, #{oc.overtimeHoursOutputId}" 
     ajaxSingle="true"/> 
    </rich:calendar> 
    ...... 

    </c:foreach> 
</a4j:outputPanel> 

<a4j:commandButton action="#{utilities.sendEmail('/pages/overtime/mail.xhtml')}" 
    type="submit" value="Submit" 
    reRender="status, valid1, valid2" eventsQueue="foo" status="status" 
    onclick="this.disabled=false" id="btnSubmit" 
    oncomplete="#{facesContext.maximumSeverity == null ? 'Richfaces.hideModalPanel(\'mpErrors\');' : 'Richfaces.showModalPanel(\'mpErrors\'); this.disabled=false'}"/> 
+0

我已經創建了一個版本的頁面沒有A4J組件。否則找不到一種方法。 – Alex 2010-11-24 21:09:43

回答

1

只有這樣做的方法是將這些ajax組件包裝在面板組中並使用呈現的屬性。您基本上需要提供條件渲染並提供ajax組件的非ajax替代方案。

所以,你會碰到這樣的:

<h:panelGroup rendered="#{someBean.ajaxEnabled}"> 
    <a4j:commandButton ..... /> 
</h:panelGroup> 

<h:panelGroup rendered="#{!someBean.ajaxEnabled}"> 
    <h:commandButton ..... /> 
</h:panelGroup> 
相關問題