Developing the Application Backend
The application developer is primarily responsible for developing the backend part of the application; in other words, the classes that handle business logic and data.
For the newsletter subscription form, the application developer may
create a class called Subscriber
to hold the
subscriber information:
package com.mycompany.newsservice.models; public class Subscriber { private String emailAddr; private String[] subscriptionIds; public String getEmailAddr( ) { return emailAddr; } public void setEmailAddr(String emailAddr) { this.emailAddr = emailAddr; } public String[] getSubscriptionIds( ) { return subscriptionIds; } public void setSubscriptionIds(String[] subscriptionIds) { this.subscriptionIds = subscriptionIds; } }
The Subscriber
class adheres to the JavaBeans
method naming
conventions—“properties” are
defined by methods for getting their values, named
get
plus the name of the property, and methods for
setting their values, named set
plus the property
name. As you’ll see shortly, this makes it easy to
use properties of this class as JSF UI component models.
When a subscription is registered or updated, the information must be
saved somewhere, likely in a database. The application developer may
decide to develop a separate class responsible for this task or put
this logic in the Subscriber
class. To keep the
example simple, we’ll add a method that represents
this behavior to the Subscriber
class. Also, instead of saving the information in a database, ...
Get JavaServer Faces 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.