About CRUD Applications
See Also
A Create, Read, Update, and Destroy (CRUD) application is a simple programming pattern that allows you to read and manage the data in a data source. The IDE provides automatic support for this common programming task by letting you quickly generate a CRUD application from an entity class.
The CRUD application is a web application that uses the JSF framework. An entity class is a class that uses the Java Persistence API to access data in a data source. You can generate a CRUD application from an entity class in a web application using the JSF Pages frorm Entity Class file template in the Persistence category of the New File wizard.
The IDE generates the following artifacts for a CRUD application:
- Controller classes. A controller class is a wrapper for an entity class that provides clients with access to the database through the methods in the entity class. For example, the controller class has methods for creating and deleting an entry in the data source, getting all of the entries in the data source, or getting a specific entry in the data source. The controller, together with faces-config.xml, also specifies navigation between pages. The IDE creates one controller for each entity class and places the controller in the same package as the entity class. The controller class is registered as a JSF managed bean in faces-config.xml.
- Converter classes. A converter class converts data from the data source into strings that are displayed in list boxes and menus and vice versa. The converter class is registered as a JSF converter in faces-config.xml.
- JSP pages. The JSP pages are the web user interface for accessing the data in the data source. For each entity class, the IDE creates four JSP pages that let you view, edit, create, and destroy entries in the data source.
An entity class is a class that uses the Java Persistence API to access a data source. In a web application project, you can generate a series of JSP pages that use the JSF framework and the entity classes to provide read and write access to the entries in the database. The JSP pages use JSF components.
To generate JSF pages from an entity class:
- Choose File > New File (Ctrl-N) from the main menu.
- From the Persistence category, select JSF Pages from Entity Class and click Next. The wizard displays all of the entity classes in the project.
- Add all of the entity classes for which you want to generate JSF pages to the Selected Entity Classes list and click Next.
- (Optional) Specify a folder in which to place the JSF pages.
- Specify a package name for the generated Java classes and click Finish.
The IDE generates the following artifacts for a CRUD application:
- Controller classes. A controller class is a wrapper for an entity class that provides clients with access to the database through the methods in the entity class. For example, the controller class has methods for creating and deleting an entry in the data source, getting all of the entries in the data source, or getting a specific entry in the data source. The IDE creates one controller for each entity class and places the controller in the same package as the entity class.
- Converter classes. A converter class takes input from the form and converts it into the type that matches the data in the data source.
- JSP pages. The JSP pages are the web user interface for accessing the data in the data source. For each entity class, the IDE creates four JSP pages that let you view, edit, create, and destroy entries in the data source.
- See Also
- About Web Application Frameworks
- Adding JSF Support to an Existing Application
- Generating JSF Pages from an Entity Class
- Creating an Entity Class
- Generating Persistent Entity Classes from a Database
Legal Notices