Skip to content

Commit 80b5476

Browse files
committed
Added documentation.
A few layout fixes.
1 parent 76ec28f commit 80b5476

5 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/main/java/com/cortez/samples/javaee7angular/data/Person.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import javax.persistence.Id;
55

66
/**
7+
* Simple entity.
8+
*
79
* @author Roberto Cortez
810
*/
911
@Entity

src/main/java/com/cortez/samples/javaee7angular/pagination/PaginatedListWrapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import java.util.List;
44

55
/**
6+
* Wraps all the information needed to paginate a table.
7+
*
68
* @author Roberto Cortez
79
*/
810
public class PaginatedListWrapper<T> {

src/main/java/com/cortez/samples/javaee7angular/rest/PersonResource.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import java.util.List;
1313

1414
/**
15+
* REST Service to expose the data to display in the UI grid.
16+
*
1517
* @author Roberto Cortez
1618
*/
1719
@Stateless

src/main/webapp/css/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ body {
1010

1111
.gridStyle {
1212
border: 1px solid rgb(212, 212, 212);
13-
height: 180px;
13+
height: 185px;
1414
}

src/main/webapp/script/person.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var app = angular.module('persons', ['ngGrid', 'ui.bootstrap']);
22

33
app.controller('personsList', function ($scope, $http) {
4+
// Makes the REST request to get the data to populate the grid.
45
$scope.refreshGrid = function (page) {
56
$http({
67
url: 'resources/persons',
@@ -15,22 +16,26 @@ app.controller('personsList', function ($scope, $http) {
1516
});
1617
};
1718

19+
// Do something when the grid is sorted.
20+
// The grid throws the ngGridEventSorted that gets picked up here and assigns the sortInfo to the scope.
21+
// This will allow to watch the sortInfo in the scope for changed and refresh the grid.
1822
$scope.$on('ngGridEventSorted', function (event, sortInfo) {
1923
$scope.sortInfo = sortInfo;
20-
2124
});
2225

26+
// Watch the sortInfo variable. If changes are detected than we need to refresh the grid.
27+
// This also works for the first page access, since we assign the initial sorting in the initialize section.
2328
$scope.$watch('sortInfo', function () {
2429
$scope.refreshGrid($scope.persons.currentPage);
2530
}, true);
2631

32+
// Initialize required information: sorting, the first page to show and the grid options.
2733
$scope.sortInfo = {fields: ['id'], directions: ['asc']};
2834
$scope.persons = {currentPage : 1};
29-
3035
$scope.gridOptions = {
3136
data: 'persons.list',
3237
useExternalSorting: true,
33-
sortinfo: $scope.sortInfo
38+
sortInfo: $scope.sortInfo
3439
};
3540
});
3641

0 commit comments

Comments
 (0)