Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Threads in Java web app

Status
Not open for further replies.

fayevalentine

Programmer
Jun 2, 2004
38
MX
Hello again,

I am having trouble with a functionality in my java web application using PrimeFaces, I hope someone can guide me.

I launch a query in an Oracle database when I click a button (this query can last a little based in a date range the user selects)
so I have more or less this code:

Java:
ReportTh et  //This is my class extends Thread, where I write my report
public void genReport()
{
  //Here I connect with my database
  //I launch the report functionality as a Thread
  et = new ReportTh(date1, date2);
  //I start the thread
  Thread th = new Thread(et);
  th.start();
  //to make my sample more compact I do not write Exception, but I have them.

}

public void cancelReport()
{
    et.terminate();
}

When I call "genReport()" with a button, appears a loading bar and a "Cancel" button in case I want to cancel the report.
but if I do not want to, I cant get to dissapear my loading box and appear a new one with a "Download" button.
Here is my code for the buttons:

Java:
<p:commandButton id="genReport" value="Generar" widgetVar="genButton" actionListener="#{reportBean.genReport}" onclick="PF('statusDialog').show();" update="panel1"  icon="ui-icon-check" ajax="true" />

<p:dialog widgetVar="statusDialog" modal="true" draggable="false" closable="false" resizable="false" showHeader="false" >
   <h:panelGrid columns="1" cellpadding="2">
      <p:graphicImage name="ajaxloadingbar.gif" />
   </h:panelGrid>
   <p:commandButton id="CancelReport" value="Cancelar" widgetVar="canButton" actionListener="#{electroBean.cancelReport}"/>
</p:dialog>

<p:dialog modal="true" resizable="false" header="Values" widgetVar="dlg" showEffect="fold">
   <p:panelGrid id="display" columns="2" columnClasses="label,value">
         <p:commandButton id="downloadLink" value="Descargar Report" widgetVar="desButton" >
              <p:fileDownload value="#{electroBean.prepDownload}" />
          </p:commandButton>
   </p:panelGrid>
</p:dialog>


I Hope someone can guide me or tell me if my approaching is not the correct one, what can I research.

Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top