← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3627: WIP: added jquery plugin for general paging (for dhis). Only partially implemented in dataentryfo...

 

------------------------------------------------------------
revno: 3627
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-05-16 16:21:57 +0200
message:
  WIP: added jquery plugin for general paging (for dhis). Only partially implemented in dataentryform. Basic functionality should be OK.
added:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementOperands.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementOperandsAction.java
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCategoryOptionCombos.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroups.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElements.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataSets.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicatorGroups.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicators.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitGroups.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitLevels.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnits.vm
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.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-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCategoryOptionCombos.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCategoryOptionCombos.vm	2011-01-22 20:56:30 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCategoryOptionCombos.vm	2011-05-16 14:21:57 +0000
@@ -7,4 +7,8 @@
 	"default": "$coc.isDefault()"
   }#if( $velocityCount < $size ),#end
 #end
-] }
+]
+#if( $usePaging ),
+	"paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" )
+#end
+}

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroups.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroups.vm	2010-12-12 19:49:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroups.vm	2011-05-16 14:21:57 +0000
@@ -6,4 +6,8 @@
     "name": "$!encoder.jsonEncode( ${dataElementGroup.name} )"
   }#if( $velocityCount < $size ),#end
 #end
-] }
+]
+#if( $usePaging ),
+	"paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" )
+#end
+}

=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementOperands.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementOperands.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementOperands.vm	2011-05-16 14:21:57 +0000
@@ -0,0 +1,21 @@
+#set( $size = $operands.size() )
+{ "operands": [
+#foreach( $operand in $operands )
+  {
+  	"operandName": "$!{operand.operandName}",
+    "dataElement": {
+    	"id": "$!{operand.dataElement.id}",
+    	"name": "$!{operand.dataElement.name}",
+    	"type": "$!{operand.dataElement.type}"
+    },
+    "categoryOptionCombo": {
+    	"id": "$!{operand.categoryOptionCombo.id}",
+    	"name": "$!{operand.categoryOptionCombo.name}"
+    }
+  }#if( $velocityCount < $size ),#end
+#end
+]
+#if( $usePaging ),
+	"paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" )
+#end
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElements.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElements.vm	2010-12-12 19:49:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElements.vm	2011-05-16 14:21:57 +0000
@@ -12,4 +12,8 @@
 	"zeroIsSignificant": "$!{dataElement.zeroIsSignificant}"
   }#if( $velocityCount < $size ),#end
 #end
-] }
+]
+#if( $usePaging ),
+	"paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" )
+#end
+}

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataSets.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataSets.vm	2010-12-12 19:49:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataSets.vm	2011-05-16 14:21:57 +0000
@@ -8,4 +8,8 @@
     "periodTypeId": "$!{dataSet.periodTypeId}"
   }#if( $velocityCount < $size ),#end
 #end
-] }
\ No newline at end of file
+]
+#if( $usePaging ),
+	"paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" )
+#end
+}

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicatorGroups.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicatorGroups.vm	2010-12-12 19:49:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicatorGroups.vm	2011-05-16 14:21:57 +0000
@@ -6,4 +6,8 @@
     "name": "$!encoder.jsonEncode( ${indicatorGroup.name} )"    
   }#if( $velocityCount < $size ),#end
 #end
-] }
\ No newline at end of file
+]
+#if( $usePaging ),
+	"paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" )
+#end
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicators.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicators.vm	2010-12-12 19:49:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicators.vm	2011-05-16 14:21:57 +0000
@@ -11,4 +11,8 @@
     "indicatorTypeId": $!{indicator.indicatorType.id}
   }#if( $velocityCount < $size ),#end
 #end
-] }
\ No newline at end of file
+]
+#if( $usePaging ),
+	"paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" )
+#end
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitGroups.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitGroups.vm	2010-12-12 19:49:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitGroups.vm	2011-05-16 14:21:57 +0000
@@ -6,4 +6,8 @@
     "name": "$!encoder.jsonEncode( ${group.name} )"
   }#if( $velocityCount < $size ),#end    
 #end
-] }
+]
+#if( $usePaging ),
+	"paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" )
+#end
+}

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitLevels.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitLevels.vm	2010-12-12 19:49:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitLevels.vm	2011-05-16 14:21:57 +0000
@@ -6,4 +6,8 @@
     "level": "$level.level"
   }#if( $velocityCount < $size ),#end    
 #end
-] }
+]
+#if( $usePaging ),
+	"paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" )
+#end
+}

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnits.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnits.vm	2010-12-12 19:49:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnits.vm	2011-05-16 14:21:57 +0000
@@ -9,5 +9,8 @@
     "hasChildrenWithCoordinates": $!{unit.hasChildrenWithCoordinates()}
   }#if( $velocityCount < $size ),#end
 #end
-] }
- 
\ No newline at end of file
+]
+#if( $usePaging ),
+	"paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" )
+#end
+}

=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js	2011-05-16 14:21:57 +0000
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * @author mortenoh
+ */
+
+(function($) {
+  var templates = {
+    button: "<button id='${id}' style='width: 80px; margin-bottom: 4px; margin-top: 4px;'>${text}</button>",
+    option: "<option>${text}</option>",
+    option_selected: "<option selected='selected'>${text}</option>",
+    wrapper: "<div id='${id}' style='padding: 0; margin: 0;' />",
+    pagesize_input: "<input id='${id}' type='text' style='width: 100px;'/>",
+    filter_input: "<input id='${id}'></input>",
+    select_page: "<select id='${id}'></select>"
+  }
+
+  var methods = {
+    load: function(select_id) {
+        var $select = $("#" + select_id);
+        var settings = $select.data("settings");
+        var params = settings.params;
+
+        var id = $select.attr("id");
+        var wrapper_id = id + "_wrapper";
+        $wrapper = $("#" + wrapper_id);
+        var select_page_id = id + "_select_page";
+        var $select_page = $("#" + select_page_id);
+        var next_button_id = id + "_next_button";
+        var $next_button = $("#" + next_button_id);
+        var previous_button_id = id + "_previous_button";
+        var $previous_button = $("#" + previous_button_id);
+        var filter_input_id = id + "_filter_input";
+        var pagesize_input_id = id + "_pagesize_input";
+        var $pagesize_input = $("#" + pagesize_input_id);
+
+        $.getJSON(settings.url, $.param( settings.params ), function(json) {
+            $select.empty();
+            $select_page.empty();
+
+            params.currentPage = json.paging.currentPage;
+            params.numberOfPages = json.paging.numberOfPages;
+            params.pageSize = json.paging.pageSize;
+            params.startPage = json.paging.startPage;
+
+            settings.handler($select, json);
+
+            for(var j=1; j<=params.numberOfPages; j++) {
+                if(params.currentPage == j) {
+                  $select_page.append( $.tmpl(templates.option_selected, {"text": j}) );
+                } else {
+                  $select_page.append( $.tmpl(templates.option, {"text": j}) );
+                }
+            }
+
+            $("#" + pagesize_input_id).val( params.pageSize );
+
+            $previous_button.removeAttr("disabled");
+            $next_button.removeAttr("disabled");
+
+            if(params.currentPage == params.startPage) {
+                $previous_button.attr("disabled", "disabled");
+            }
+
+            if(params.currentPage == params.numberOfPages) {
+                $next_button.attr("disabled", "disabled");
+            }
+
+            settings.params = params;
+            $select.data("settings", settings);
+         });
+    },
+    init: function(options) {
+      var settings = { }
+      var params = { }
+
+      $.extend(settings, options);
+      $.extend(params, options.params);
+      params.usePaging = true;
+
+      var $select = $(this);
+      var id = $(this).attr("id");
+      var wrapper_id = id + "_wrapper";
+      var select_page_id = id + "_select_page";
+      var next_button_id = id + "_next_button";
+      var previous_button_id = id + "_previous_button";
+      var filter_input_id = id + "_filter_input";
+      var pagesize_input_id = id + "_pagesize_input";
+
+      $select.wrap( $.tmpl(templates.wrapper, { "id": wrapper_id }) );
+      $wrapper = $("#" + wrapper_id);
+
+      $wrapper.append( $.tmpl(templates.select_page, { "id": select_page_id }) )
+      $select_page = $("#" + select_page_id);
+
+      $wrapper.append( $.tmpl(templates.button, { "id": previous_button_id, "text":"previous" }) );
+      $previous_button = $("#" + previous_button_id);
+
+      $wrapper.append( $.tmpl(templates.button, { "id": next_button_id, "text":"next" }) );
+      $next_button = $("#" + next_button_id);
+
+      $wrapper.append( $.tmpl(templates.pagesize_input, { "id": pagesize_input_id }) );
+      $pagesize_input = $("#" + pagesize_input_id);
+
+      settings.params = params;
+      $select.data("settings", settings);
+      methods.load("" + id);
+
+      $next_button.click(function() {
+          params.currentPage = +params.currentPage + 1;
+          settings.params = params;
+          $select.data("settings", settings);
+
+          methods.load("" + id);
+      });
+
+      $previous_button.click(function() {
+          params.currentPage = +params.currentPage - 1;
+          settings.params = params;
+          $select.data("settings", settings);
+
+          methods.load("" + id);
+      });
+
+      $select_page.change(function() {
+          params.currentPage = +$(this).find(":selected").val();
+          settings.params = params;
+          $select.data("settings", settings);
+
+          methods.load("" + id);
+      });
+
+      $pagesize_input.change(function() {
+         params.pageSize = +$(this).val();
+         params.currentPage = 1;
+         settings.params = params;
+         $select.data("settings", settings);
+
+         methods.load("" + id);
+      });
+    }
+  }
+
+  $.fn.dhisPaging = function(method) {
+    if(methods[method]) {
+      return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
+    } else if (typeof method === 'object' || !method) {
+      return methods.init.apply(this, arguments);
+    } else {
+      $.error('Method ' +  method + ' does not exist on jQuery.dhisPaging' );
+    }  
+  };
+})(jQuery);

=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementOperandsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementOperandsAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementOperandsAction.java	2011-05-16 14:21:57 +0000
@@ -0,0 +1,129 @@
+package org.hisp.dhis.commons.action;
+
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataelement.DataElementOperand;
+import org.hisp.dhis.dataelement.comparator.DataElementOperandNameComparator;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.paging.ActionPagingSupport;
+
+/**
+ * @author mortenoh
+ */
+public class GetDataElementOperandsAction
+    extends ActionPagingSupport<DataElementOperand>
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+    private DataSetService dataSetService;
+
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+
+    private DataElementCategoryService dataElementCategoryService;
+
+    public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService )
+    {
+        this.dataElementCategoryService = dataElementCategoryService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input & Output
+    // -------------------------------------------------------------------------
+
+    private Integer dataSetId;
+
+    public void setDataSetId( Integer dataSetId )
+    {
+        this.dataSetId = dataSetId;
+    }
+
+    private String key;
+
+    public void setKey( String key )
+    {
+        this.key = key;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    public List<DataElementOperand> operands;
+
+    public List<DataElementOperand> getOperands()
+    {
+        return operands;
+    }
+
+    private DataSet dataSet;
+
+    public DataSet getDataSet()
+    {
+        return dataSet;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        if ( dataSetId != null )
+        {
+            dataSet = dataSetService.getDataSet( dataSetId );
+
+            operands = new ArrayList<DataElementOperand>( dataElementCategoryService.getFullOperands( dataSet
+                .getDataElements() ) );
+        }
+        else
+        {
+            operands = new ArrayList<DataElementOperand>();
+        }
+
+        Collections.sort( operands, new DataElementOperandNameComparator() );
+
+        if ( usePaging )
+        {
+            this.paging = createPaging( operands.size() );
+
+            operands = operands.subList( paging.getStartPos(), paging.getEndPos() );
+        }
+
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2011-05-13 12:34:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2011-05-16 14:21:57 +0000
@@ -398,6 +398,11 @@
         <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
 	</bean>
 
+    <bean id="org.hisp.dhis.commons.action.GetDataElementOperandsAction" class="org.hisp.dhis.commons.action.GetDataElementOperandsAction" scope="prototype">
+      <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+      <property name="dataElementCategoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
+    </bean>
+
 	<bean id="org.hisp.dhis.commons.action.GetOperandsAction" class="org.hisp.dhis.commons.action.GetOperandsAction" scope="prototype">
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="dataElementCategoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2011-05-10 08:07:40 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2011-05-16 14:21:57 +0000
@@ -538,6 +538,12 @@
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
+        <action name="getDataElementOperands" class="org.hisp.dhis.commons.action.GetDataElementOperandsAction">
+          <result name="success" type="velocity-json">
+            /dhis-web-commons/ajax/jsonDataElementOperands.vm</result>
+          <param name="onExceptionReturn">plainTextError</param>
+        </action>
+
 		<action name="getOperands" class="org.hisp.dhis.commons.action.GetOperandsAction">
 			<result name="success" type="velocity-json">
 				/dhis-web-commons/ajax/jsonOperands.vm</result>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm	2011-05-12 23:33:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm	2011-05-16 14:21:57 +0000
@@ -1,3 +1,4 @@
+<script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js"></script>
 <script type="text/javascript" src="javascript/viewDataEntryForm.js"></script>
 <script type="text/javascript">
 	jQuery(document).ready(function() {
@@ -11,6 +12,47 @@
 		
 		jQuery('#designTextarea').ckeditor();
 		jQuery("#designTextarea").ckeditorGet().setData('$encoder.jsEscape( $dataEntryValue, "'" )');
+
+		jQuery("#dataElementSelector").dhisPaging({
+			url: "../dhis-web-commons-ajax-json/getDataElementOperands.action",
+			handler: function(element, json) {
+				jQuery.each(json.operands, function(i, item) {
+					var option = jQuery("<option />");
+					option.addClass("dataElementSelectorOption");
+					option.text( item.operandName );
+					option.data( "dataelement-id", item.dataElement.id );
+					option.data( "dataelement-name", item.dataElement.name );
+					option.data( "dataelement-type", item.dataElement.type );
+					option.data( "optioncombo-id", item.categoryOptionCombo.id );
+					option.data( "optioncombo-name", item.categoryOptionCombo.name );
+					option.dblclick(insertDataElement);
+
+                	element.append( option );
+            	});
+			},
+			params: {
+				dataSetId: $dataSet.id
+			}
+		});
+
+		jQuery("#indicatorSelector").dhisPaging({
+			url: "../dhis-web-commons-ajax-json/getIndicators.action",
+			handler: function(element, json) {
+				jQuery.each(json.indicators, function(i, item) {
+					var option = jQuery("<option />");
+					option.addClass("indicatorSelectorOption");
+					option.text( item.name );
+					option.data("id", item.id);
+					option.dblclick(insertIndicator);
+
+                	element.append( option );
+            	});
+			},
+			params: {
+				dataSetId: $dataSet.id,
+				pageSize: 10
+			}
+		});
 	});
 
     var stat = "ADD";
@@ -126,16 +168,7 @@
 
 			<tr id="dataElementsTab">
 				<td colspan="2">
-					<select id="dataElementSelector" multiple="multiple" style="height: 200px; width: 100%;">
-					#foreach( $operand in $operands )
-						<option class="dataElementSelectorOption"
-								data-idx="${velocityCount}"
-								data-dataelement-id="$operand.dataElement.id" data-dataelement-name="$operand.dataElement.name" data-dataelement-type="$operand.dataElement.type"
-								data-optioncombo-id="$operand.categoryOptionCombo.id" data-optioncombo-name="$operand.categoryOptionCombo.name" ondblclick="insertDataElement()">
-							$encoder.htmlEncode( $operand.operandName )
-						</option>
-					#end
-					</select>
+					<select id="dataElementSelector" multiple="multiple" style="height: 200px; width: 100%;"></select>
 				</td>
 			</tr>
 
@@ -150,12 +183,7 @@
 
 			<tr id="indicatorsTab">
 				<td colspan="2">
-					<select id="indicatorSelector" multiple="multiple" style="height: 200px; width: 100%;">
-					#foreach( $indicator in $indicators )
-						<option class="indicatorSelectorOption"
-								data-idx="${velocityCount}" data-id="${indicator.id}" ondblclick="insertIndicator()">$encoder.htmlEncode( $indicator.name )</option>
-					#end
-					</select>
+					<select id="indicatorSelector" multiple="multiple" style="height: 200px; width: 100%;"></select>
 				</td>
 			</tr>