FileDocCategorySizeDatePackage
BookDisplayForm.javaAPI DocExample3578Thu Dec 15 20:58:34 GMT 2005com.oreilly.jent.jsf.library.backing

BookDisplayForm

public class BookDisplayForm extends Object
Implementation of the BookDisplayForm Class. We could use the Directory to get the Library, but we want to show how property injection in managed beans works.

Fields Summary
private String
currentBookID
private com.oreilly.jent.jsf.library.model.Library
library
Constructors Summary
Methods Summary
public java.lang.StringcheckBookIn()

        Book book = getBook(); // get the current book
        book.setCheckedOut(false);
        return null;
    
public java.lang.StringcheckBookOut()

        Book book = getBook(); // get the current book
        book.setCheckedOut(true);
        return null;
    
public com.oreilly.jent.jsf.library.model.BookgetBook()

        if (currentBookID == null) return null;
        return (Book)getLibrary().getBooks().get(currentBookID);
    
public javax.faces.model.SelectItem[]getBookList()

        Library library = Directory.getLibrary();
        List books = library.getBookList();
        SelectItem[] items = new SelectItem[books.size()];
        for (int i = 0; i < books.size(); i++) {
            Book book = (Book)books.get(i);
            items[i] = new SelectItem(book.getTrackingID(), book.getTitle());
        }
       return items;
    
public java.lang.StringgetCurrentBookID()


       
        return currentBookID;
    
public com.oreilly.jent.jsf.library.model.LibrarygetLibrary()

        return library;
    
public booleanisBookSelected()

        return currentBookID != null;
    
public voidsafeModeChange(javax.faces.event.ValueChangeEvent event)

        UIComponent buttonHolderGrid =
                event.getComponent().findComponent("buttonHolder");
        if (buttonHolderGrid != null) {
            Object newVal = event.getNewValue();
            if (newVal instanceof Boolean)
                buttonHolderGrid.setRendered(!((Boolean)newVal).booleanValue());
        }
    
public voidsetCurrentBookID(java.lang.String currentBookID)

        this.currentBookID = currentBookID;
    
public voidsetLibrary(com.oreilly.jent.jsf.library.model.Library library)

        this.library = library;