Main Interface (original) (raw)

The main interface allows students and staff to check students in and out, and record when students are outside at the playground.

The following topics are addressed here:

Java Persistence API Entities Used in the Main Interface

The following entities used in the main interface encapsulate data stored and manipulated by Duke’s Tutoring, and are located in thedukestutoring.entity package in the dukes-tutoring-common project.

Enterprise Beans Used in the Main Interface

The following enterprise beans used in the main interface provide the business logic for Duke’s Tutoring, and are located in thedukestutoring.ejb package in the dukes-tutoring-war project:

WebSocket Endpoint Used in the Main Interface

The javaeetutorial.dukestutoring.web.websocket.StatusEndpoint class is a WebSocket server endpoint that returns students and their status to client endpoints. The StatusEndpoint.updateStatus method is a CDI observer method for the StatusEvent event. When a student’s status changes in the main interface, a StatusEvent is fired. TheupdateStatus observer method is called by the container, and pushes out the status change to all the client endpoints registered withStatusEndpoint.

The index.xhtml JavaServer Faces page contains JavaScript code to connect to the WebSocket endpoint. The onMessage method on this page clicks a JavaServer Faces button, which makes an Ajax request to refresh the table that shows the current status of the students.

Facelets Files Used in the Main Interface

The Duke’s Tutoring application uses Facelets to display the user interface, making extensive use of the templating features of Facelets. Facelets, the default display technology for JavaServer Faces technology, consists of XHTML files located in the_tut-install_/examples/case-studies/dukes-tutoring-war/src/main/webapp/directory.

The following Facelets files are used in the main interface:

Helper Classes Used in the Main Interface

The following helper classes, found in the dukes-tutoring-commonproject’s dukestutoring.util package, are used in the main interface.

Properties Files

The strings used in the main interface are encapsulated into resource bundles to allow the display of localized strings in multiple locales. Each of the properties files has locale-specific files appended with locale codes, containing the translated strings for each locale. For example, Messages_es.properties contains the localized strings for Spanish locales.

The dukes-tutoring-common project has the following resource bundle under src/main/resources/.

The dukes-tutoring-war project has the following resource bundles under src/main/resources/.

Deployment Descriptors Used in Duke’s Tutoring

Duke’s Tutoring uses these deployment descriptors in thesrc/main/webapp/WEB-INF directory of the dukes-tutoring-war project:

Duke’s Tutoring also uses the following deployment descriptor in thesrc/main/resources/META-INF directory of the dukes-tutoring-commonproject:

No enterprise bean deployment descriptor is used in Duke’s Tutoring. Annotations in the enterprise bean class files are used for the configuration of enterprise beans in this application.