I have a button that calls a method from the backing Bean. This method allows to extract data from parsing html code. While the method is running i have a dialog showing a progress bar and a command button Cancel
. I need when the user click the cancel button the method called by the extract button stops.
This is my html code:
<p:commandButton
value="Start" style="width: 12%;height: 100%"
update=":confirmPurchase, :confirmPurchaseTest, :mainform" id="extractbutton"
ajax="true" widgetVar="ButtonExtract"
actionListener="#{mailMB.searchEmails()}"
icon="ui-icon-disk" styleClass="ui-priority-primary"
onstart="blockUIWidget1.show();" oncomplete=" blockUIWidget1.hide();" />
<p:dialog widgetVar="blockUIWidget1" header="Hitonclick" modal="true"
resizable="false" closable="false">
<table border="0" style="width: 500px">
<tbody >
<tr>
<td>
<p:graphicImage url="pictures/loading81.gif" width="200" height="200" alt="animated-loading-bar"/>
</td>
<td>
<h:outputLabel value="Extracting is in progress. Please wait..."/>
<div align="center">
<p:commandButton value="Cancel" title="Cancel" />
</div>
</td>
</tr>
<div align="right">
</div>
</tbody>
</table>
</p:dialog>
And here is my searchEmails method in my sessionScoped Bean
public void searchEmails() throws Exception {
idCustomer = (String) session.getAttribute("idCustomer");
System.out.println(idCustomer + " this is it");
Customer customer = customerBusinessLocal.findById(idCustomer);
data = dataBusinessLocal.createData(new Date(), number, keyword, moteur, customer, State.REJECTED);
mails = mailBusinessLocal.createEmails(keyword, number, moteur, data);
System.out.println("Method was invoked");
}
How can i stop the searchEmails method from running via the cancel command button?