Canceling an Ajax Request in RichFaces

I have a problem with canceling an Ajax request. Our application interface is built in the Russian Federation.

There should be a cancel button on the progress bar β€” this is an interrupt operation, for example, to cancel filling control from the database. How to do it?

I tried using the overload page, flags with "if" conditions on the getters for the controls, and also using "bypassUpdates" without positive effects.

Thank you in advance for your help.

XHTML (button):

<a4j:commandButton id="showData" value="View" styleClass="hBtn" disabled="#{events.isButtonsDisabled}" oncomplete="if (#{facesContext.maximumSeverity==null}) {window.open('/seed/pages/data.jsf','DATA')};" actionListener="#{events.actionShow}"/> 

JAVA: (button):

 public void actionShow(ActionEvent evt) { //Some logic, getting data from database } 

XHTML (Home - showing a pending pop-up)

 <a4j:form> <a4j:status id="ajaxStat" onstart="Richfaces.showModalPanel('waitPanel');" onstop="#{rich:component('waitPanel')}.hide()" /> </a4j:form> 

XHTML (popup):

 <rich:modalPanel id="waitPanel" autosized="true" moveable="false" minWidth="250" styleClass="popup"> <f:facet name="header"> <h:panelGroup> <h:outputText value="Operation in progress"></h:outputText> </h:panelGroup> </f:facet> <f:facet name="controls"> <h:panelGroup> <h:graphicImage value="../images/icons/action_close.gif" styleClass="hidelink" id="hidelink"/> <rich:componentControl for="waitPanel" attachTo="hidelink" operation="hide" event="onclick"/> </h:panelGroup> </f:facet> <a4j:form id="msgFrm" ajaxSubmit="true"> <h:outputText value="Please wait..."/> <h:graphicImage styleClass="progressBar" value="../images/indicatorbar.gif"/> <a4j:commandButton value="Cancel" type="button" onclick="#{rich:component('waitPanel')}.hide()" action="#{main.cancelAction}" bypassUpdates="true"/> </a4j:form> </rich:modalPanel> 

JAVA (popup):

 public void cancelAction(){ //there was setter for true/false flag for actionShow() here, now there is nothing here (it was not working) } 
+4
source share
1 answer

Reload the page stops all current ajax requests. This does not stop java beans support from completing requests, but I assume this is not a question. c: if and ajax rendering don't mix very well. Perhaps you can use "rendered" to disable control updates? Then divide the control into two parts. One is shown with reliable data and, for example, bright blue. The other is displayed without any data and has a gray image.

But ... I'm not sure I understood the question correctly.

Edit 23-1-2012: Having seen the code, I would say that cancelAction should set a flag, which then completes the action that is executed inside actionShow (). Then an ajax request is made and the popup closes. I can’t understand why this will not work.

+1
source

Source: https://habr.com/ru/post/1384145/


All Articles