289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
299 |
300 |
301 |
302 |
303 | ----
304 |
305 | The `greeting.xhtml` file uses the HTML RenderKit and the `components`
306 | resource library tag libraries. The `components` tag library has a
307 | prefix of `fc`, and is used to specify the `inputDate` composite
308 | component in the form below. The
309 | `` tag has
310 | the required `date` attribute, and it stores the value in the `yourBD`
311 | property in the `DukesBDay` managed bean by using the Jakarta Expression Language
312 | `#{dukesBDay.yourBD}`.
313 |
314 | The localized strings are referenced by the Jakarta Expression Language
315 | `\#{bundle.``property-name``}`. For example, the
316 | `` tag will display the
317 | following string in English locales:
318 |
319 | [source,oac_no_warn]
320 | ----
321 | Hi. I'm Duke. Let's find out who's older -- you or I.
322 | ----
323 |
324 | The `` tag creates a Submit button and specifies that a
325 | successful submission should render the `response.xhtml` file by setting
326 | the `action` attribute to `#{dukesBDay.processBirthday}`. The
327 | `processBirthday` method returns the value `"/response.xhtml"`. The
328 | `action` attribute is used to define navigation rules for forms in
329 | Facelets pages.
330 |
331 | The `response.xhtml` file displays the age difference between the user
332 | and Duke and the average age difference of all users so far. Different
333 | strings are displayed based on whether the user is the same age,
334 | younger, or older than Duke. The text can be displayed or not based on
335 | the conditions specified by the `rendered` attribute of the
336 | `` tag. The conditions used in the `rendered` attribute
337 | are Jakarta Expression Language alternatives to the Java programming
338 | language conditional operators to allow XML parsing of the XHTML file.
339 |
340 | [[sthref11]][[GIMVG]]
341 |
342 | Table 4-1 Conditional Operator Jakarta Expression Language Alternatives
343 |
344 | [width="60%",cols="25%,40%,35%"]
345 | |=======================================================================
346 | |*Logical Condition* |*Java Programming Language Conditional Operator* |*Jakarta Expression Language
347 | Alternative*
348 | |AND a|
349 | `&&`
350 |
351 |
352 | a|
353 | `&&`
354 |
355 |
356 | |EQUALS a|
357 | `==`
358 |
359 |
360 | a|
361 | `==`
362 |
363 |
364 | |LESS THAN a|
365 | `<`
366 |
367 |
368 | |`lt`
369 |
370 | |GREATER THAN |`>` |`gt`
371 | |=======================================================================
372 |
373 |
374 | Here's the content of the `response.xhtml` file.
375 |
376 | [source,oac_no_warn]
377 | ----
378 |
379 |
381 |
383 |
384 | Response Page
385 |
386 |
387 |
388 |
389 |
391 |
393 |
395 |
397 |
399 |
401 |
403 |
405 |
407 |
408 |
410 |
411 |
412 |
413 |
414 |
415 | ----
416 |
417 | For example, the `\#{bundle.SameAge}` string is displayed if the user and
418 | Duke have the same birthday, as specified by the condition
419 | `#{dukesBDay.ageDiff == 0}` in the `rendered` attribute. That is, the
420 | following string is displayed when the `ageDiff` property of `DukesBDay`
421 | equals `0`:
422 |
423 | [source,oac_no_warn]
424 | ----
425 | You are the same age as Duke!
426 | ----
427 |
428 | The form also contains a `` tag that creates a *Back*
429 | button, which directs the user back to the `greeting.xhtml` page, as
430 | specified in the `action` attribute.
431 |
432 | [[GIMTA]][[add-the-form-to-greeting.xhtml]]
433 |
434 | Add the Form to greeting.xhtml
435 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
436 |
437 | Add the form that provides the user interface for displaying Duke's age
438 | and specifying the user's birthday.
439 |
440 | 1. Expand *Deployed Resources*, then `webapp`, and open `greeting.xhtml`,
441 | in the editor window, replace the text between the `` and ``
442 | tags with the following:
443 | +
444 | [source,oac_no_warn]
445 | ----
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
459 | ----
460 | 2. In the editor window, right-click and select *Source* -> *Format*.
461 | 3. From the *File* menu, select *Save*.
462 |
463 | [[GIMVW]][[add-the-form-to-response.html]]
464 |
465 | Add the Form to response.html
466 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
467 |
468 | Add a form that displays the age difference between Duke and the user,
469 | displays the average age difference of all users, and allows the user to
470 | navigate back to `greeting.xhtml`.
471 |
472 | 1. Expand *Deployed Resources*, then `webapp`, and open `response.xhtml`,
473 | in the editor window, replace the text between the `` and ``
474 | tags with the following:
475 | +
476 | [source,oac_no_warn]
477 | ----
478 |
479 |
481 |
483 |
485 |
487 |
489 |
491 |
493 |
495 |
497 |
498 |
500 |
501 |
502 | ----
503 | 2. In the editor window, right-click and select *Source* -> *Format*.
504 | 3. From the *File* menu, select *Save*.
505 |
--------------------------------------------------------------------------------
/src/main/jbake/content/web-application006.adoc:
--------------------------------------------------------------------------------
1 | type=page
2 | status=published
3 | title=Building, Packaging, Deploying, and Running the firstcup-war Web Application
4 | next=next-steps.html
5 | prev=web-application005.html
6 | ~~~~~~
7 | = Building, Packaging, Deploying, and Running the firstcup-war Web Application
8 |
9 |
10 | [[GCTNX]][[building-packaging-deploying-and-running-the-firstcup-war-web-application]]
11 |
12 | Building, Packaging, Deploying, and Running the firstcup-war Web Application
13 | ----------------------------------------------------------------------------
14 |
15 | In this section, you will build the `firstcup-war` web application,
16 | deploy it to the server, and run the application.
17 |
18 | [[GCTOJ]][[build-package-and-deploy-the-firstcup-war-web-application]]
19 |
20 | Build, Package, and Deploy the firstcup-war Web Application
21 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 |
23 | Before we finish, we need to create a run configuraton to start the embedded
24 | database for us.
25 |
26 | 1. Go to *Run* -> *External Tools* -> *External Tools Configurations...*.
27 | 2. At *External Tools Configuration* dialog click in *Program* and *New launch configuration* icon.
28 | 3. Then give a name to the shortcut at field *Name:*.
29 | 4. At *Location:* field click in *Browse File System...* and search for your GlassFish installation.
30 | 5. In your Glassfish installation root folder, go to bin folder.
31 | 6. Select `asadmin.bat` if you are in Windows, otherwise select `asadmin.sh` and click *OK*.
32 | 7. In *Arguments:* text area put `start-database`.
33 | 8. Click *Apply* and *Run*.
34 |
35 | Now the internal database is already running.
36 |
37 |
38 | Now build and package the `DukesBirthdayBean` enterprise bean, the
39 | `FirstcupUser` entity, and the `firstcup-war` web client into a WAR
40 | file, `firstcup-war.war`, then deploy it to the server.
41 |
42 |
43 | 1. Click the *Servers* tab.
44 | 2. Right-click the GlassFish Server instance and go to *Add and Remove...*.
45 | 3. At *Add and Remove...* dialog, select the `firstcup-war` artifact and click *Add >*.
46 | 4. Click *Finish*.
47 | 5. Right-click the GlassFish Server instance and click *Start*.
48 |
49 | After `firstcup-war.war` deploys successfully to GlassFish Server,
50 | go to `http://localhost:8080/firstcup-war/` url.
51 |
52 | [[GCTQC]][[run-the-firstcup-war-application]]
53 |
54 | Run the firstcup-war Application
55 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56 |
57 | 1. On the greeting page, enter your birth date in the *Your birthday*
58 | field. Make sure you use the date pattern specified on the page:
59 | MM/dd/yyyy.
60 | 2. Click *Submit*.
61 | 3. After the `response.xhtml` page is displayed, click *Back* to return
62 | to the `greeting.xhtml` page.
63 | 4. Enter a different birthday in the text field and click *Submit* again
64 | to see how the average age of First Cup users changes.
65 |
66 | Congrats !
--------------------------------------------------------------------------------
/src/main/jbake/jbake.properties:
--------------------------------------------------------------------------------
1 | site.host=http://jbake.org
2 | render.tags=false
3 | render.sitemap=false
4 | render.archive=false
5 | render.feed=false
6 | asciidoctor.option.safe=0
7 | asciidoctor.attributes.export=true
8 |
--------------------------------------------------------------------------------
/src/main/jbake/templates/footer.ftl:
--------------------------------------------------------------------------------
1 | <#-- a footer template fragment included in the page template -->
2 |
3 |
4 |