Is it possible to disable AJAX in RichFaces?
Is it possible in a Seam/RichFaces page to disable AJAX so requests are sent via regular server-client request, where the entire page i开发者_StackOverflows refreshed instead of individual elements? I'm using an a4j:outputPanel
and an a4j:commandButton
and need to have them not use AJAX in some cases via a toggle button.
Here's a code snippet from the page. Thanks.
<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'}"/>
Only way to do it is to wrap these ajax components in panelgroups and use the rendered property. You'll basically need to provide conditional rendering and provide non-ajax alternatives of the ajax components.
So you would have something like :
<h:panelGroup rendered="#{someBean.ajaxEnabled}">
<a4j:commandButton ..... />
</h:panelGroup>
<h:panelGroup rendered="#{!someBean.ajaxEnabled}">
<h:commandButton ..... />
</h:panelGroup>
精彩评论