All language subtitles for 005 Implement List Users Feature

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese Download
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,900 --> 00:00:08,450 Next, let's implement the list users feature in the users management module 2 00:00:09,400 --> 00:00:11,700 in our Bookstore website 3 00:00:12,500 --> 00:00:18,200 Here's our task list: first we need to code a ListUsersServlet 4 00:00:18,900 --> 00:00:22,320 then we code the UserService class 5 00:00:23,000 --> 00:00:24,529 and we... 6 00:00:25,300 --> 00:00:33,220 code the Users list page in HTML and JSTL 7 00:00:35,000 --> 00:00:40,400 JSTL stands for JSP Standard Tag Libraries 8 00:00:41,200 --> 00:00:49,800 We don't use Java code or JSP code directly in the JSP page 9 00:00:50,200 --> 00:00:58,320 instead we use JSTL - a set of the XML tags 10 00:00:59,500 --> 00:01:01,010 okay 11 00:01:02,700 --> 00:01:12,820 And this sequence diagram shows you how this list users feature work 12 00:01:13,500 --> 00:01:14,320 you see 13 00:01:14,900 --> 00:01:18,160 the request... 14 00:01:20,800 --> 00:01:26,100 the request coming from the client.. 15 00:01:26,900 --> 00:01:30,600 ...will be handled by the ListUsersServlet 16 00:01:31,400 --> 00:01:37,500 this servlet invokes the listUser() method on the UserService class request 17 00:01:38,200 --> 00:01:45,600 In turn, the UserService class invokes the listAll() method on the UserDAO class 18 00:01:45,800 --> 00:01:58,000 and in turn, the UserDAO class invokes the findWithNamedQuery() method of a superclass - JpaDAO 19 00:01:59,300 --> 00:02:03,400 and the return is a list of user 20 00:02:04,000 --> 00:02:05,000 you see 21 00:02:05,500 --> 00:02:15,000 this is the workflow - this is the sequence of method calls in the list users feature 22 00:02:16,300 --> 00:02:21,000 and this is the design of the users list page 23 00:02:21,000 --> 00:02:22,500 you see 24 00:02:25,900 --> 00:02:27,460 we have... 25 00:02:28,500 --> 00:02:35,860 a table that displays all users in the application 26 00:02:37,700 --> 00:02:41,400 let's review the naming convention 27 00:02:41,700 --> 00:02:45,660 which we discussed earlier in this course 28 00:02:46,400 --> 00:02:48,200 this is the... 29 00:02:48,900 --> 00:02:51,520 name convention for DAO classes 30 00:02:51,800 --> 00:02:56,720 this is the name convention for service classes 31 00:02:58,900 --> 00:03:00,400 so you see 32 00:03:03,400 --> 00:03:06,180 Our service classes... 33 00:03:06,500 --> 00:03:11,000 for the user service is UserServices 34 00:03:15,300 --> 00:03:20,180 and for the servlet class... 35 00:03:20,900 --> 00:03:25,520 it will be ListUsersServlet, okay? 36 00:03:28,500 --> 00:03:32,600 and URL mapping convention... 37 00:03:33,200 --> 00:03:36,260 for listing pages... 38 00:03:37,200 --> 00:03:39,200 listing pages 39 00:03:40,800 --> 00:03:47,000 the URL mapping for the list users feature is... 40 00:03:48,000 --> 00:03:50,800 /list_users 41 00:03:51,100 --> 00:03:52,200 and... 42 00:03:53,600 --> 00:04:02,000 because it is in the back-end, it is after the admin 43 00:04:03,700 --> 00:04:04,800 okay 44 00:04:07,400 --> 00:04:13,000 and this is the name convention for the JSP pages or listing pages 45 00:04:13,500 --> 00:04:15,540 the convention is... 46 00:04:16,200 --> 00:04:29,600 _list.jsp - so in our case, our JSP page for listing user is user_list.jsp 47 00:04:30,300 --> 00:04:34,880 Now let's create the ListUsersServlet class 48 00:04:35,700 --> 00:04:40,200 in the com.bookstore.controller.admin package 49 00:04:40,800 --> 00:04:45,120 right-click here New > Servlet 50 00:04:46,200 --> 00:04:51,240 the class name is ListUsersServlet 51 00:04:52,800 --> 00:04:54,200 click Next 52 00:04:55,000 --> 00:04:59,160 and under the URL mappings, click Edit 53 00:05:00,300 --> 00:05:12,000 the URL pattern for this servlet is /admin/list_users 54 00:05:12,620 --> 00:05:19,240 as per the naming convention I have reminded you 55 00:05:21,400 --> 00:05:24,700 okay, and click Finish 56 00:05:25,500 --> 00:05:28,720 we have the servlet class here... 57 00:05:30,200 --> 00:05:33,200 removes the doPost() method 58 00:05:37,000 --> 00:05:44,000 and delete the unnecessary comments 59 00:05:57,600 --> 00:05:59,040 okay 60 00:06:11,200 --> 00:06:18,700 and as shown in the sequence diagram. the ListUsersServlet invokes the UserService class, so... 61 00:06:19,200 --> 00:06:25,300 Now let's create the UserService class 62 00:06:26,400 --> 00:06:31,160 as per the naming convention it should be UserServices 63 00:06:34,500 --> 00:06:37,700 we create the services class under the... 64 00:06:38,000 --> 00:06:41,000 this package: com.bookstore.service 65 00:06:41,300 --> 00:06:43,600 New > Class 66 00:06:44,500 --> 00:06:49,940 the class name is UserServices 67 00:06:50,600 --> 00:06:52,140 click Finish 68 00:06:52,500 --> 00:06:53,560 okay 69 00:06:59,300 --> 00:07:05,500 and this UserServices class implements a listUser() method 70 00:07:06,300 --> 00:07:13,300 this UserServices class uses the UserDAO class so 71 00:07:14,000 --> 00:07:17,500 they need to have a... 72 00:07:19,400 --> 00:07:24,040 an instance of the UserDAO class here 73 00:07:24,900 --> 00:07:26,460 UserDAO 74 00:07:26,700 --> 00:07:27,480 okay 75 00:07:27,700 --> 00:07:31,400 and first method is listUser() method 76 00:07:52,900 --> 00:07:57,500 and we create a constructor 77 00:07:59,800 --> 00:08:02,120 Generate constructors from superclass 78 00:08:02,700 --> 00:08:04,000 okay 79 00:08:13,700 --> 00:08:20,100 We need to create a new instance of the UserDAO class here 80 00:08:20,100 --> 00:08:21,380 new 81 00:08:23,200 --> 00:08:29,000 you see, the UserDAO class requires an EntityManager 82 00:08:29,820 --> 00:08:40,789 so we need to create an EntityManager object from the EntityManagerFactory 83 00:08:41,900 --> 00:08:54,000 so we also an EntityManagerFactory here 84 00:08:58,400 --> 00:09:00,300 entityManagerFactory 85 00:09:00,300 --> 00:09:05,700 and also an EntityManager 86 00:09:07,000 --> 00:09:09,610 entityManager 87 00:09:09,800 --> 00:09:11,460 okay 88 00:09:11,800 --> 00:09:18,260 so now we need to create the EntityManagerFactory 89 00:09:18,600 --> 00:09:21,760 entityManagerFactory 90 00:09:22,100 --> 00:09:26,780 = Persistence 91 00:09:29,000 --> 00:09:31,800 createEntityManagerFactory 92 00:09:32,700 --> 00:09:35,230 and persistence unit 93 00:09:35,700 --> 00:09:49,000 persistence unit name is the unit name we specified in the persistence.xml file here 94 00:09:51,300 --> 00:09:55,000 you see, this is BookStoreWebsite 95 00:09:55,200 --> 00:09:56,500 okay 96 00:10:03,600 --> 00:10:09,200 Now, create an EntityManager from the EntityManagerFactory 97 00:10:09,500 --> 00:10:22,000 entityManager = entityManagerFactory.createEntityManager() 98 00:10:24,300 --> 00:10:27,820 and in the listUser() method, we... 99 00:10:32,200 --> 00:10:41,890 call the UserDAO's listAll() method that returns a list of Users objects 100 00:10:44,600 --> 00:10:46,260 listUsers 101 00:10:46,700 --> 00:10:47,900 okay 102 00:10:59,300 --> 00:11:02,960 in the ListUsersServlet class... 103 00:11:03,700 --> 00:11:05,480 in doGet() method 104 00:11:06,200 --> 00:11:08,000 we... 105 00:11:10,600 --> 00:11:22,720 send response to the list users JSP page using the RequestDispatcher 106 00:11:24,500 --> 00:11:32,900 so we need to create a JSP page in the WebContent/admin directory 107 00:11:34,000 --> 00:11:39,000 right-click here > New > JSP File 108 00:11:39,900 --> 00:11:46,120 file name is user_list.jsp 109 00:11:47,400 --> 00:11:48,940 okay 110 00:11:51,300 --> 00:11:59,000 and copy the skeleton of the index.jsp 111 00:12:03,900 --> 00:12:05,140 copy 112 00:12:15,800 --> 00:12:20,740 delete the content of the index.jsp 113 00:12:21,800 --> 00:12:23,440 okay 114 00:12:26,300 --> 00:12:36,400 and the title is Users List - 115 00:12:36,900 --> 00:12:38,500 okay 116 00:12:42,400 --> 00:12:44,780 Manage Users 117 00:12:47,500 --> 00:12:50,240 Manage Users 118 00:12:55,600 --> 00:13:00,560 the heading is Users Management 119 00:13:01,100 --> 00:13:02,780 management 120 00:13:04,400 --> 00:13:09,200 as you can see in the Users List Page design here 121 00:13:09,600 --> 00:13:15,220 the heading of the page is Users Management 122 00:13:20,200 --> 00:13:23,300 Now in the ListUsersServlet... 123 00:13:24,300 --> 00:13:28,080 we call RequestDispatcher 124 00:13:28,080 --> 00:13:33,000 request.getRequestDispatcher() 125 00:13:34,800 --> 00:13:39,820 this is the listPage 126 00:13:49,000 --> 00:13:54,640 listPage points to the JSP page 127 00:13:56,100 --> 00:13:58,000 which is in... 128 00:13:58,100 --> 00:14:02,700 which is the user_list.jsp 129 00:14:09,300 --> 00:14:10,500 requestDispatcher 130 00:14:10,600 --> 00:14:11,940 okay 131 00:14:12,100 --> 00:14:19,800 and requestDispatcher.forward(request, response) 132 00:14:19,900 --> 00:14:27,800 to forward the request to the destination JSP page 133 00:14:28,200 --> 00:14:29,170 request 134 00:14:30,000 --> 00:14:31,000 sorry 135 00:14:33,300 --> 00:14:35,300 request, response 136 00:14:35,500 --> 00:14:37,000 okay 137 00:14:40,300 --> 00:14:42,080 this is the request 138 00:14:42,400 --> 00:14:43,920 okay 139 00:15:06,100 --> 00:15:16,000 Now let's start the server to test this servlet 140 00:15:17,600 --> 00:15:21,180 right-click on the server > Start 141 00:15:34,800 --> 00:15:39,270 Now refresh the admin's page 142 00:15:40,100 --> 00:15:41,460 okay, and... 143 00:15:41,460 --> 00:15:46,060 click on the Users link 144 00:15:47,000 --> 00:15:52,000 oh, you see: we get 404 error 145 00:15:52,990 --> 00:16:00,140 it's because the URL is wrong, so we need to edit the header 146 00:16:01,200 --> 00:16:02,520 header 147 00:16:06,300 --> 00:16:12,000 this should be list_users 148 00:16:13,600 --> 00:16:20,400 that matches the URL mapping of the ListUsersServlet 149 00:16:21,000 --> 00:16:23,000 you see 150 00:16:25,000 --> 00:16:28,200 because we are already in the admin 151 00:16:29,100 --> 00:16:29,740 okay 152 00:16:30,100 --> 00:16:31,540 so... 153 00:16:33,700 --> 00:16:38,000 the list_users is relative to the admin 154 00:16:38,400 --> 00:16:39,500 okay 155 00:16:41,500 --> 00:16:47,500 and you can see: this is the URL pattern of the servlet class 156 00:16:47,900 --> 00:16:51,670 /admin/list_users 157 00:16:51,800 --> 00:16:55,780 but in the JSP page we're already in the admin 158 00:16:55,900 --> 00:16:56,620 okay 159 00:16:56,900 --> 00:17:05,000 so in the header we specify a relative path which is list_users only 160 00:17:05,500 --> 00:17:06,400 you see 161 00:17:09,400 --> 00:17:12,000 Now refresh the page 162 00:17:15,400 --> 00:17:21,500 Now, you can see the URL appears in the bottom 163 00:17:22,099 --> 00:17:23,220 click here 164 00:17:24,079 --> 00:17:24,599 you see 165 00:17:24,700 --> 00:17:36,270 the servlet class - ListUsersServlet is called, so you can see the Users Management text here 166 00:17:43,500 --> 00:17:50,700 and now let's update something in the user_list.jsp page 167 00:17:51,400 --> 00:17:57,960 for example, we create a hyperlink: Create New User 168 00:18:08,100 --> 00:18:10,600 Create New User 169 00:18:10,900 --> 00:18:11,600 okay 170 00:18:12,100 --> 00:18:14,800 let's refresh the page 171 00:18:16,000 --> 00:18:17,240 click Users 172 00:18:17,600 --> 00:18:18,760 you can see 173 00:18:19,400 --> 00:18:21,620 the hyperlink appears 174 00:18:22,700 --> 00:18:26,560 Next, let's create the table 175 00:18:27,600 --> 00:18:30,740 as per the design using HTML code 176 00:18:31,400 --> 00:18:35,600 we create a table 177 00:18:37,500 --> 00:18:41,180 in this div section 178 00:18:43,400 --> 00:18:45,160 179 00:18:50,800 --> 00:18:53,580 give it a border 180 00:18:56,900 --> 00:19:01,140 border size is 1 pixel 181 00:19:03,300 --> 00:19:04,860 new table row 182 00:19:05,700 --> 00:19:06,960 and... 183 00:19:08,400 --> 00:19:09,720 heading 184 00:19:10,400 --> 00:19:12,000 index 185 00:19:14,000 --> 00:19:18,380 next heading is ID, email, full name and actions 186 00:19:18,500 --> 00:19:19,820 ID 187 00:19:21,900 --> 00:19:23,840 Full name 188 00:19:25,500 --> 00:19:26,400 Email 189 00:19:26,700 --> 00:19:28,090 Email 190 00:19:31,300 --> 00:19:32,660 Full name 191 00:19:33,800 --> 00:19:34,920 and... 192 00:19:35,600 --> 00:19:37,980 actions 193 00:19:52,900 --> 00:19:58,000 you can see the result in the internal web browser 194 00:19:59,500 --> 00:20:01,340 refresh 195 00:20:07,500 --> 00:20:09,200 Users 196 00:20:11,700 --> 00:20:13,580 and you can see the table here 197 00:20:14,100 --> 00:20:18,140 the heading of the table 198 00:20:31,100 --> 00:20:40,940 need to create a blank line between the hyperlink Create New User and the table 199 00:20:48,000 --> 00:20:55,880 we can wrap the link under heading 3 tag

200 00:20:56,800 --> 00:20:58,880 and refresh 201 00:21:01,300 --> 00:21:03,000 you see 202 00:21:06,500 --> 00:21:15,000 we need to send the list of Users objects from the servlet class to the JSP page 203 00:21:15,800 --> 00:21:19,760 so in the servlet class here... 204 00:21:21,300 --> 00:21:26,000 we create a new instance of UserServices class 205 00:21:26,400 --> 00:21:29,080 UserServices 206 00:21:30,900 --> 00:21:34,200 userServices = new UserServices() 207 00:21:34,500 --> 00:21:35,220 okay 208 00:21:35,800 --> 00:21:41,260 userServices.listUser() 209 00:21:43,000 --> 00:21:45,289 this... 210 00:21:47,500 --> 00:21:51,499 should return the user list 211 00:21:56,690 --> 00:21:59,880 return listUsers 212 00:22:09,600 --> 00:22:14,160 you can see while we are updating the Java code... 213 00:22:14,800 --> 00:22:19,560 Tomcat is automatically reloading our web application 214 00:22:20,300 --> 00:22:24,000 to make the change take effect automatically 215 00:22:26,500 --> 00:22:31,020 Now in the listUsersServlet class... 216 00:22:41,900 --> 00:22:52,400 we assign the returned result to a List here 217 00:22:53,000 --> 00:22:54,060 List 218 00:22:54,900 --> 00:22:59,000 List from java.util 219 00:23:02,200 --> 00:23:03,480 Users 220 00:23:04,200 --> 00:23:06,260 listUsers = userServices.listUser() 221 00:23:06,260 --> 00:23:07,080 okay 222 00:23:13,200 --> 00:23:20,200 and we send the listUsers to the JSP page via the request 223 00:23:20,700 --> 00:23:24,720 request.setAttribute() 224 00:23:25,300 --> 00:23:29,440 name the attribute is listUsers 225 00:23:32,700 --> 00:23:37,980 and it stores the data is the listUsers 226 00:23:38,600 --> 00:23:40,200 okay 227 00:23:47,900 --> 00:23:58,800 and now in the JSP page we can use JSTL tag to extract the data from the listUsers object here 228 00:23:59,200 --> 00:24:02,200 in the JSP page 229 00:24:05,240 --> 00:24:12,220 in JSTL we can use the JSTL's forEach tag 230 00:24:13,500 --> 00:24:16,460 but we need to... 231 00:24:18,700 --> 00:24:22,000 include a taglib directive... 232 00:24:22,900 --> 00:24:23,780 so... 233 00:24:24,200 --> 00:24:34,000 switch to the browser you can search for JSTL core taglib 234 00:24:36,500 --> 00:24:39,600 click on the first result here and you can see 235 00:24:40,000 --> 00:24:42,000 we need to copy this... 236 00:24:42,500 --> 00:24:49,240 this is the directive specifies the JSTL core tags 237 00:24:51,800 --> 00:24:53,640 paste it here 238 00:24:55,600 --> 00:24:56,680 okay 239 00:24:57,000 --> 00:25:05,500 and then we can use the JSTL forEach tag to iterate over a collection 240 00:25:06,500 --> 00:25:07,540 you see 241 00:25:19,300 --> 00:25:24,000 here we can use the 242 00:25:27,300 --> 00:25:37,000 for each User object in the collection we create a new table row 243 00:25:41,000 --> 00:25:42,360 and... 244 00:25:44,300 --> 00:25:46,700 the var attribute... 245 00:25:47,300 --> 00:25:50,780 var attribute... 246 00:25:53,100 --> 00:25:58,000 ...is the variable name which is used in the for loop 247 00:25:58,700 --> 00:26:00,080 user 248 00:26:00,500 --> 00:26:01,600 and... 249 00:26:02,300 --> 00:26:03,660 items 250 00:26:04,600 --> 00:26:12,400 point to the variable name - the listUsers in the request 251 00:26:13,000 --> 00:26:15,100 you can see 252 00:26:15,200 --> 00:26:23,000 this name listUsers must match the name we specify the attribute 253 00:26:23,500 --> 00:26:25,000 okay 254 00:26:35,500 --> 00:26:39,440 and status - varStatus... 255 00:26:40,400 --> 00:26:45,000 specify the name of the status variable state test 256 00:26:45,300 --> 00:26:46,000 status 257 00:26:46,100 --> 00:26:47,160 okay 258 00:26:48,300 --> 00:26:53,410 create a new table cell using a

tag 259 00:26:59,000 --> 00:27:05,000 the first column is the index column which is... 260 00:27:06,200 --> 00:27:18,000 which displays the numbers of rows in alphanumeric order 261 00:27:20,300 --> 00:27:23,100 so we can use this... 262 00:27:34,000 --> 00:27:36,600 status.index 263 00:27:36,700 --> 00:27:37,700 okay 264 00:27:38,400 --> 00:27:46,320 Now let's refresh the page to see how it works 265 00:27:58,200 --> 00:27:59,180 you can see 266 00:27:59,500 --> 00:28:03,480 the index appears here: 0 1 2 3 267 00:28:03,900 --> 00:28:10,800 which corresponds to 4 rows in the database table 268 00:28:11,000 --> 00:28:17,600 And you can see here: in the users table we have 4 rows: 1 2 3 4 269 00:28:19,800 --> 00:28:21,340 and... 270 00:28:22,600 --> 00:28:28,200 we can +1 to make it starts form 1 instead of 0 271 00:28:28,700 --> 00:28:37,400 and the next column is the ID of the user 272 00:28:38,000 --> 00:28:43,000 user.id 273 00:28:45,700 --> 00:28:54,000 user is the variable name here - that represents a Users object in the listUsers collection 274 00:28:54,500 --> 00:29:02,200 and you can use the object-oriented syntax here: user. and followed by a field name 275 00:29:03,900 --> 00:29:07,920 so in our Users class... 276 00:29:08,300 --> 00:29:10,900 userId - our field name is userId 277 00:29:10,900 --> 00:29:12,000 okay 278 00:29:14,400 --> 00:29:16,400 userId 279 00:29:17,800 --> 00:29:22,220 Now, refresh the page 280 00:29:23,000 --> 00:29:25,340 refresh in Chrome browser 281 00:29:27,900 --> 00:29:32,000 you see ID: 4-2-3-1 the 282 00:29:35,600 --> 00:29:38,600 the next column is email 283 00:29:39,900 --> 00:29:42,100 email 284 00:29:44,400 --> 00:29:49,540 user.email 285 00:29:49,700 --> 00:29:51,240 okay 286 00:29:53,800 --> 00:29:55,565 save the file and refresh 287 00:29:55,700 --> 00:29:56,700 you see 288 00:29:56,900 --> 00:30:03,759 the email appears here: david, sophia, you and nam 289 00:30:05,300 --> 00:30:08,160 david, sophia, you and nam 290 00:30:09,300 --> 00:30:23,800 you can see the order is different because in the query we order the result by the full name of the user 291 00:30:24,600 --> 00:30:30,840 you can see the Users class here 292 00:30:31,100 --> 00:30:34,800 select u from Users u order by u.fullName 293 00:30:35,000 --> 00:30:37,540 and now let's display the full name 294 00:30:37,800 --> 00:30:38,700 295 00:30:39,300 --> 00:30:43,340 ${user.fullName} 296 00:30:52,400 --> 00:30:54,240 let's refresh the page 297 00:30:54,500 --> 00:30:55,500 you see 298 00:30:55,700 --> 00:30:59,800 full name: David Beckham, Miss Sophia, Mr President and Nam Ha Minh 299 00:31:00,200 --> 00:31:08,700 this is sorted by the full name field in ascending oder: D M M N 300 00:31:08,800 --> 00:31:10,000 you see 301 00:31:13,200 --> 00:31:16,100 and as per design, in the Actions column, we... 302 00:31:16,200 --> 00:31:20,040 for each user we have the Edit and Delete link 303 00:31:20,100 --> 00:31:21,500 okay 304 00:31:28,700 --> 00:31:31,100 Edit 305 00:31:34,300 --> 00:31:37,200 a space, and.. 306 00:31:40,600 --> 00:31:42,180 Delete 307 00:31:45,700 --> 00:31:48,460 Now let's refresh the page 308 00:31:49,800 --> 00:31:50,820 you see 309 00:31:51,300 --> 00:31:55,000 that looks similar to the design 310 00:31:55,600 --> 00:31:57,040 you see 311 00:31:59,600 --> 00:32:06,600 of course later, we will improve the look and feel of our page 312 00:32:07,000 --> 00:32:08,640 For now, you... 313 00:32:09,100 --> 00:32:15,200 you focus on make it works first and make it looks better later 314 00:32:15,300 --> 00:32:16,500 okay 315 00:32:21,900 --> 00:32:28,000 let's specify the cellpadding attribute... 316 00:32:28,800 --> 00:32:36,000 for the table equals 5 to make more spaces in the cells of the table 317 00:32:36,400 --> 00:32:37,540 refresh 318 00:32:38,000 --> 00:32:44,040 and you see, it looks better, right? 319 00:32:50,800 --> 00:32:56,520 and we can test by inserting a new user to the table 320 00:32:58,500 --> 00:33:04,300 execute the test case testCreateUsers 321 00:33:04,900 --> 00:33:08,720 and new user is... 322 00:33:09,800 --> 00:33:12,460 for example, email... 323 00:33:14,200 --> 00:33:15,100 john 324 00:33:20,900 --> 00:33:21,860 John Smith 325 00:33:21,860 --> 00:33:22,500 okay 326 00:33:23,000 --> 00:33:26,220 password is johnny 327 00:33:27,200 --> 00:33:30,140 and run this test case 328 00:33:31,700 --> 00:33:35,090 Run As > JUnit Test 329 00:33:39,900 --> 00:33:40,860 successful 330 00:33:40,860 --> 00:33:41,860 okay 331 00:33:42,100 --> 00:33:46,200 Now refresh the list users page 332 00:33:46,600 --> 00:33:47,660 you see 333 00:33:48,600 --> 00:33:51,320 john... JohnSmith... appears here 334 00:33:51,800 --> 00:33:58,080 but the result is sorted by full name of the users 335 00:33:58,600 --> 00:33:59,500 you see 336 00:34:05,900 --> 00:34:08,480 and now, let's try to update something 337 00:34:11,600 --> 00:34:15,000 for example we update the... 338 00:34:18,100 --> 00:34:19,300 email 339 00:34:19,800 --> 00:34:21,000 update the... 340 00:34:21,199 --> 00:34:25,620 update users set email =... 341 00:34:26,600 --> 00:34:32,000 email of John, email of you is... 342 00:34:38,400 --> 00:34:42,980 you2018@gmail.com 343 00:34:44,500 --> 00:34:46,000 where... 344 00:34:47,699 --> 00:34:53,940 user_id = 3 345 00:34:55,000 --> 00:34:55,780 updated 346 00:34:55,780 --> 00:34:57,700 Now let's refresh the page 347 00:34:58,100 --> 00:35:08,000 and we should see that the email you@gmail.com should be updated 348 00:35:09,000 --> 00:35:12,300 you see it is updated to you2018... 349 00:35:12,500 --> 00:35:13,800 very good 350 00:35:16,300 --> 00:35:17,371 that's it! 351 00:35:17,600 --> 00:35:22,700 so far we have implemented the list users feature 352 00:35:22,900 --> 00:35:28,780 in the users management module in our Bookstore website 353 00:35:31,900 --> 00:35:39,400 we have written code that follows this sequence 354 00:35:39,700 --> 00:35:44,000 ListUsersServlet calls listUser on the UserServices 355 00:35:45,100 --> 00:35:49,820 and the UserServices call listAll() on the UserDAO 356 00:35:50,200 --> 00:35:51,930 and so on... 357 00:35:52,800 --> 00:35:53,920 you see here 358 00:35:54,100 --> 00:35:55,860 let's review 359 00:35:56,000 --> 00:35:59,010 ListUsersServlet 360 00:36:00,400 --> 00:36:02,220 from the... 361 00:36:03,600 --> 00:36:07,720 No, I review from the... 362 00:36:08,800 --> 00:36:12,400 header - the header - the user clicks on the Users link 363 00:36:12,600 --> 00:36:13,340 you see 364 00:36:13,500 --> 00:36:17,920 and this calls the servlet 365 00:36:18,500 --> 00:36:21,580 the servlet's doGet() method 366 00:36:23,500 --> 00:36:27,100 calls the listUser() method from the UsersServices 367 00:36:28,100 --> 00:36:33,400 and the UserServices calls the listAll() method on the UserDAO class 368 00:36:33,900 --> 00:36:44,000 and the listAll() method calls findWithNamedQuery() of the JpaDAO class 369 00:36:47,800 --> 00:36:48,660 you see 370 00:36:49,200 --> 00:36:51,280 that's how it works 371 00:36:52,800 --> 00:36:59,420 and the result is we have a list users page 372 00:37:00,700 --> 00:37:01,860 completed 373 00:37:04,000 --> 00:37:12,900 And in the next video, we will implement code for the create new user feature 24130

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.