|
MyEclipse 下开发JSF教程(5) // ------------------------- Properties --------------------------- Collection books;
// ------------------------- Getter and Setter --------------------
/** * @return collection of books */ public Collection getBooks(){
SimulateDB simulateDB = new SimulateDB();
/* Holt sich die Session auf dem Externen Context */ Map session = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
/* Lies alle Bücher auf der simulierten DateNBAnk aus */ books = simulateDB.getAllBooks(session);
return books; }
/** * @param books The books to set. */ public void setBooks(Collection books) { this.books = books; } }
Your package eXPlorer will look like the picture below. Java/国外教程下载/LaLiLuna%20-%20Tutorials%20for%20struts,%20ejb,%20myeclipse%20»%20First%20Java%20Server%20Faces%20Tutorial.files/package-eXPlorer.gif" width=325 align=left border=0 name=Graphic6>
Action listener methodsTo provide that a user can add, edit or delete a book, we have to include the appropriate functionality. This functionality will be implemented in action listener methods / classes. If an event occur (ex.: a user clicks on a link) an action listener method / class will be called and processed. Open the class Book and add four methods , which process the following functionality. Initializise a book Edit a book Save a book Delete a book
Initialize a book/**
|