← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9672: Fixed bug<111003> big-sql-views-result-in-browser-crash by using paging for the result.

 

------------------------------------------------------------
revno: 9672
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-01-31 12:16:05 +0700
message:
  Fixed bug<111003> big-sql-views-result-in-browser-crash by using paging for the result.
added:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewGrid.vm
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ExportSqlViewResultAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ExportSqlViewResultAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ExportSqlViewResultAction.java	2013-01-28 19:43:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ExportSqlViewResultAction.java	2013-01-31 05:16:05 +0000
@@ -28,11 +28,10 @@
  */
 
 import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.sqlview.SqlView;
 import org.hisp.dhis.sqlview.SqlViewService;
 
-import com.opensymphony.xwork2.Action;
-
 /**
  * Updates a existing sqlview in database.
  * 
@@ -40,7 +39,7 @@
  * @version $Id ExportSqlViewResultAction.java July 12, 2010$
  */
 public class ExportSqlViewResultAction
-    implements Action
+    extends ActionPagingSupport<Grid>
 {
     private static final String DEFAULT_TYPE = "html";
 
@@ -105,6 +104,10 @@
         sqlView = sqlViewService.getSqlView( id );
         
         grid = sqlViewService.getSqlViewGrid( sqlView, null );
+        
+        this.paging = this.createPaging( grid.getHeight() );
+
+        grid.limitGrid( paging.getStartPos(), paging.getEndPos() );
 
         return type != null ? type : DEFAULT_TYPE;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml	2013-01-21 14:03:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml	2013-01-31 05:16:05 +0000
@@ -336,6 +336,17 @@
       <param name="requiredAuthorities">F_SQLVIEW_MANAGEMENT</param>
     </action>
 
+    <action name="showDataSqlViewByAjax" class="org.hisp.dhis.dataadmin.action.sqlview.ExportSqlViewResultAction">
+	  <result name="csv" type="gridCsvResult" />
+      <result name="xls" type="gridXlsResult" />
+      <result name="pdf" type="gridPdfResult" />
+      <result name="html" type="velocity">/content.vm</result>
+      <param name="page">
+        /dhis-web-maintenance-dataadmin/showDataSqlViewGrid.vm</param>
+      <param name="javascripts">javascript/sqlView.js</param>
+      <param name="requiredAuthorities">F_SQLVIEW_MANAGEMENT</param>
+    </action>
+
     <!-- Constant Name -->
 
     <action name="getConstant" class="org.hisp.dhis.dataadmin.action.constant.GetConstantAction">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js	2013-01-28 16:38:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js	2013-01-31 05:16:05 +0000
@@ -1,3 +1,4 @@
+isAjax = true;
 
 function validateAddUpdateSqlView( mode )
 {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm	2013-01-28 16:38:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm	2013-01-31 05:16:05 +0000
@@ -1,11 +1,16 @@
-<style type="text/css">
-.gridTable th, .gridTable td
-{
-  text-align: center;
-  width: 150px;
-  line-height: 170%;
-}
-</style>
+<script type="text/javascript">
+	jQuery( document ).ready( function()
+	{	
+		contentDiv = 'showDataSqlViewContent';
+
+		if ( jQuery( '#baseLink' ).length )
+		{
+			var newBaseLink = getFieldValue( 'baseLink' ).replace( 'exportSqlView.action', 'showDataSqlViewByAjax.action' );
+			setFieldValue( 'baseLink', newBaseLink );
+		}
+	} );
+
+</script>
 
 <h3>$i18n.getString( "view_data_for" ) &quot;${sqlView.name}&quot;</h3>
 
@@ -19,31 +24,6 @@
 </div>
 <br/>
 
-<table class="listTable gridTable">
-	<thead>
-		<tr>
-		#foreach( $header in $!grid.getVisibleHeaders() )
-			<th #if( $header.meta )style="text-align:left"#end>$!encoder.htmlEncode( $header.name )</th>
-		#end
-		</tr>
-	</thead>
-	
-	<tbody>
-		#foreach( $row in $grid.getVisibleRows() )
-		<tr>
-			#foreach( $col in $row )
-			#set( $index = ( $velocityCount - 1 ) )
-			#if( $grid.getVisibleHeaders().get( $index ).meta )
-			<td style="text-align:left">$!encoder.htmlEncode( $col )</td>
-			#else
-			<td>
-				#if ($!col)$col
-				#else<span style="color:blue;font-weight:bold;">null</span>#end
-			</td>
-			#end
-			#end
-		</tr>
-		#end
-	</tbody>
-
-</table>
\ No newline at end of file
+<div id="showDataSqlViewContent">
+#parse( "/dhis-web-maintenance-dataadmin/showDataSqlViewGrid.vm" )
+</div>
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewGrid.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewGrid.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewGrid.vm	2013-01-31 05:16:05 +0000
@@ -0,0 +1,43 @@
+<style type="text/css">
+.gridTable th, .gridTable td
+{
+  text-align: center;
+  width: 150px;
+  line-height: 170%;
+}
+</style>
+
+<script type="text/javascript">
+	jQuery( document ).ready( function(){ setTableStyles(); } );
+</script>
+
+<table class="listTable gridTable">
+	<thead>
+		<tr>
+		#foreach( $header in $!grid.getVisibleHeaders() )
+			<th #if( $header.meta )style="text-align:left"#end>$!encoder.htmlEncode( $header.name )</th>
+		#end
+		</tr>
+	</thead>
+	
+	<tbody>
+		#foreach( $row in $grid.getVisibleRows() )
+		<tr>
+			#foreach( $col in $row )
+			#set( $index = ( $velocityCount - 1 ) )
+			#if( $grid.getVisibleHeaders().get( $index ).meta )
+			<td style="text-align:left">$!encoder.htmlEncode( $col )</td>
+			#else
+			<td>
+				#if ($!col)$col
+				#else<span style="color:blue;font-weight:bold;">null</span>#end
+			</td>
+			#end
+			#end
+		</tr>
+		#end
+	</tbody>
+</table>
+
+<p></p>
+#parse( "/dhis-web-commons/paging/paging.vm" )
\ No newline at end of file