Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
| 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? |