Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. <p:commandButton id='extractTimesheetButton'
  2. actionListener ="#{dataProcessingManagedBean.extractTimesheetData}"
  3. binding ="#{dataProcessingManagedBean.extractTimesheetCommandButton}" immediate="true"
  4. update='myForm:tabview:detailDataTable myForm:tabview:summaryDataTable myForm:downloadExcelsButton'
  5. ajax="false" icon="ui-icon-calculator" onclick="PF('statusDialog1').show()" >
  6.  
  7. public void extractTimesheetData() throws SQLException, ClassNotFoundException, IOException {
  8. String fromDate = dateFormat.format( ((Date)fromDateCalendar.getValue()) );
  9. String toDate = dateFormat.format( ((Date) toDateCalendar.getValue()) );
  10.  
  11. String sqlFromDate = sqlDateFormat.format( ((Date)fromDateCalendar.getValue()) );
  12. String sqltoDate = sqlDateFormat.format( ((Date)toDateCalendar.getValue()) );
  13.  
  14. detailDataCount = 0;
  15. summaryDataCount = 0;
  16.  
  17. Class.forName(COM_MYSQL_JDBC_DRIVER);
  18. Connection connection = DriverManager.getConnection(CONNECTION_STRING, USERNAME, PASSWORD);
  19. Statement statement = connection.createStatement();
  20.  
  21. long detailDataStartTime = System.currentTimeMillis();
  22. queryDetailData(sqlFromDate, sqltoDate, statement);
  23. System.out.println("Detail Time takes "+ ((System.currentTimeMillis() - detailDataStartTime) /1000) + " seconds");
  24. long summaryDataStartTime = System.currentTimeMillis();
  25. querySummaryData(fromDate, toDate, statement);
  26. System.out.println("Summary Time takes "+ ((System.currentTimeMillis() - summaryDataStartTime) /1000) + " seconds");
  27.  
  28. downloadExcelsCommandButton.setDisabled(!( detailDatas != null && detailDatas.size() > 0 && summaryDatas != null && summaryDatas.size() > 0 ));
  29. downloadExcelsCommandButton.setValue("Download excel file of data between " + fileNameDateFormat.format( this.fromDate ) +" and " + fileNameDateFormat.format( this.toDate ) );
  30.  
  31. connection.close();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement