30.4.2 Examining the WebTimeBean Class

JSF documents typically interact with one or more Java objects to perform the app’s tasks. As you saw, this example obtains the time on the server and sends it as part of the response.

JavaBeans

JavaBeans objects are instances of classes that follow certain conventions for class design. Each JavaBean class typically contains data and methods. A JavaBean exposes its data to a JSF document as properties. Depending on their use, these properties can be read/write, read-only or write-only. To define a read/write property, a JavaBean class provides set and get methods for that property. For example, to create a String property firstName, the class would provide methods with the following first lines:

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.