From f74a994cbd85731d37769e2c2a20c897ea4f154e Mon Sep 17 00:00:00 2001 From: Igor Lubimov Date: Mon, 22 Sep 2014 15:47:27 +0200 Subject: [PATCH 1/5] fix image url for Uchiha Madara --- src/main/resources/sql/load.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/sql/load.sql b/src/main/resources/sql/load.sql index c1eba81..a4959a4 100644 --- a/src/main/resources/sql/load.sql +++ b/src/main/resources/sql/load.sql @@ -6,7 +6,7 @@ INSERT INTO PERSON("ID", "NAME", "DESCRIPTION", "IMAGEURL") VALUES (5, 'Gaara', INSERT INTO PERSON("ID", "NAME", "DESCRIPTION", "IMAGEURL") VALUES (6, 'Killer Bee', 'Kumogakure', 'http://img1.wikia.nocookie.net/__cb20120215120020/naruto/images/thumb/3/36/Killer_Bee.png/300px-Killer_Bee.png') INSERT INTO PERSON("ID", "NAME", "DESCRIPTION", "IMAGEURL") VALUES (7, 'Jiraya', 'Konoha', 'http://img2.wikia.nocookie.net/__cb20120925123905/naruto/images/thumb/2/21/Profile_Jiraiya.PNG/300px-Profile_Jiraiya.PNG') INSERT INTO PERSON("ID", "NAME", "DESCRIPTION", "IMAGEURL") VALUES (8, 'Namikaze Minato', 'Konoha', 'http://img4.wikia.nocookie.net/__cb20140209115534/naruto/images/thumb/1/1f/Minato_Namikaze.PNG/300px-Minato_Namikaze.PNG') -INSERT INTO PERSON("ID", "NAME", "DESCRIPTION", "IMAGEURL") VALUES (9, 'Uchiha Madara', 'Missing-nin', 'http://img2.wikia.nocookie.net/__cb20140118022828/naruto/images/thumb/2/29/Uchiha_Madara.png/300px-Uchiha_Madara.png') +INSERT INTO PERSON("ID", "NAME", "DESCRIPTION", "IMAGEURL") VALUES (9, 'Uchiha Madara', 'Missing-nin', 'http://img2.wikia.nocookie.net/__cb20130725131804/naruto/images/thumb/b/b3/Madara%27s_Rinnegan.png/300px-Madara%27s_Rinnegan.png') INSERT INTO PERSON("ID", "NAME", "DESCRIPTION", "IMAGEURL") VALUES (10, 'Senju Hashirama', 'Konoha', 'http://img2.wikia.nocookie.net/__cb20120915132454/naruto/images/thumb/7/7e/Hashirama_Senju.png/300px-Hashirama_Senju.png') INSERT INTO PERSON("ID", "NAME", "DESCRIPTION", "IMAGEURL") VALUES (11, 'Might Guy', 'Konoha', 'http://img4.wikia.nocookie.net/__cb20140605202934/naruto/images/thumb/4/40/MightGuy.png/300px-MightGuy.png') INSERT INTO PERSON("ID", "NAME", "DESCRIPTION", "IMAGEURL") VALUES (12, 'Hyuga Neji', 'Konoha', 'http://img1.wikia.nocookie.net/__cb20130913104919/naruto/images/thumb/a/a8/Neji_Part_II.png/300px-Neji_Part_II.png') From 97013a6d75368d05b8b5a62fb8a78f80f618d556 Mon Sep 17 00:00:00 2001 From: Igor Lubimov Date: Mon, 22 Sep 2014 15:48:58 +0200 Subject: [PATCH 2/5] remove unneeded Produces-annotation for listPersons --- .../com/cortez/samples/javaee7angular/rest/PersonResource.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/cortez/samples/javaee7angular/rest/PersonResource.java b/src/main/java/com/cortez/samples/javaee7angular/rest/PersonResource.java index 7af10e9..64bf5d8 100644 --- a/src/main/java/com/cortez/samples/javaee7angular/rest/PersonResource.java +++ b/src/main/java/com/cortez/samples/javaee7angular/rest/PersonResource.java @@ -51,7 +51,6 @@ private PaginatedListWrapper findPersons(PaginatedListWrapper wrapper) { } @GET - @Produces(MediaType.APPLICATION_JSON) public PaginatedListWrapper listPersons(@DefaultValue("1") @QueryParam("page") Integer page, From 5f8be87315450aca13353434d42c7fda2f98fbf9 Mon Sep 17 00:00:00 2001 From: Igor Lubimov Date: Mon, 22 Sep 2014 15:49:25 +0200 Subject: [PATCH 3/5] added "implements Serializable" --- .../java/com/cortez/samples/javaee7angular/data/Person.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/cortez/samples/javaee7angular/data/Person.java b/src/main/java/com/cortez/samples/javaee7angular/data/Person.java index a88f350..a2da330 100644 --- a/src/main/java/com/cortez/samples/javaee7angular/data/Person.java +++ b/src/main/java/com/cortez/samples/javaee7angular/data/Person.java @@ -1,5 +1,6 @@ package com.cortez.samples.javaee7angular.data; +import java.io.Serializable; import javax.persistence.*; /** @@ -8,7 +9,7 @@ * @author Roberto Cortez */ @Entity -public class Person { +public class Person implements Serializable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id") @SequenceGenerator(name = "id", sequenceName = "id") From a8e85e6cbf9dca5ebaed54cfb3ac1da0fd5a5a08 Mon Sep 17 00:00:00 2001 From: Igor Lubimov Date: Mon, 22 Sep 2014 15:52:20 +0200 Subject: [PATCH 4/5] - use html5-conform angular attributes (ng-* -> data-ng-*); - prevent image distortion --- src/main/webapp/index.html | 70 +++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html index a5bbca0..d60e13d 100644 --- a/src/main/webapp/index.html +++ b/src/main/webapp/index.html @@ -1,6 +1,6 @@ - + javaee7-angular @@ -37,98 +37,98 @@

Java EE - Angular Application


-
- {{alert.msg}} +
+ {{alert.msg}}

-
+

List Persons

-
+
- +
-
+
-
+

Add Person

-
+

Edit Person

-
+ -
+
- + + data-ng-model="person.name" + required data-ng-minlength="2" data-ng-maxlength="50"/> -

Add Name.

-

Name must be at least 2 characters long.

-

Name cannot be longer than 50 characters.

+

Add Name.

+

Name must be at least 2 characters long.

+

Name cannot be longer than 50 characters.

-
+
- + + data-ng-model="person.description" + required data-ng-minlength="5" data-ng-maxlength="100"/> -

Add Description.

-

Description must be at least 5 characters long.

-

Description cannot be longer than 100 characters.

+

Add Description.

+

Description must be at least 5 characters long.

+

Description cannot be longer than 100 characters.

-
+
- + -

Add Image URL.

-

Invalid Image URL.

+

Add Image URL.

+

Invalid Image URL.

-
- +
+
- - + +
From 9564627ad920365968c61fc3b72a8f2785b11a7b Mon Sep 17 00:00:00 2001 From: Igor Lubimov Date: Mon, 22 Sep 2014 15:53:11 +0200 Subject: [PATCH 5/5] fix descendant sorting by column --- src/main/webapp/script/person.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/script/person.js b/src/main/webapp/script/person.js index a8e0633..d17b4ec 100644 --- a/src/main/webapp/script/person.js +++ b/src/main/webapp/script/person.js @@ -3,7 +3,7 @@ var app = angular.module('persons', ['ngResource', 'ngGrid', 'ui.bootstrap']); // Create a controller with name personsListController to bind to the grid section. app.controller('personsListController', function ($scope, $rootScope, personService) { // Initialize required information: sorting, the first page to show and the grid options. - $scope.sortInfo = {fields: ['id'], directions: ['asc']}; + $scope.sortInfo = {fields: ['id'], directions: ['asc', 'desc']}; $scope.persons = {currentPage: 1}; $scope.gridOptions = { @@ -48,7 +48,7 @@ app.controller('personsListController', function ($scope, $rootScope, personServ // Watch the sortInfo variable. If changes are detected than we need to refresh the grid. // This also works for the first page access, since we assign the initial sorting in the initialize section. - $scope.$watch('sortInfo.fields[0]', function () { + $scope.$watch('sortInfo', function () { $scope.refreshGrid(); }, true);