<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<html>
 <f:view>
 <head>
    <title>Library Books</title>
    <link rel="stylesheet" type="text/css"
          href='<%= request.getContextPath() + "/css/app.css" %>'>
 </head>
 <body>
    <h1>Library Collection</h1>
    <hr>
 <h:form>
 <table>
    <tr><td valign="top">

     <h:selectOneListbox size="10"
        value="#{bookdisplayform.currentBookID}"
        onchange="submit()">
        <f:selectItems value="#{bookdisplayform.bookList}"/>
     </h:selectOneListbox>
     <p/>
     <h:commandButton value="Return Home" action="home"/>

  </td><td valign="top">
     <h:panelGroup rendered="#{bookdisplayform.bookSelected}">
         <h:panelGrid columnClasses="rowLabel,rowContent" columns="2">
            <h:outputText value="Title:"/>
            <h:outputText value="#{bookdisplayform.book.title}"/>
            <h:outputText value="Author:"/>
            <h:outputText value="#{bookdisplayform.book.author}"/>
            <h:outputText value="ISBN:"/>
            <h:outputText value="#{bookdisplayform.book.ISBN}"/>
            <h:outputText value="Status:"/>
            <h:outputText
            value="#{bookdisplayform.book.checkedOut ? 'Checked Out' : 'Checked In'}"/>
         </h:panelGrid>

         <h:panelGroup id="buttonHolder">

         <h:panelGroup rendered="#{usersession.currentUser.borrower}">
           <h:commandButton value="Check Out" action="#{bookdisplayform.checkBookOut}"
                rendered="#{not bookdisplayform.book.checkedOut}"/>
         </h:panelGroup>

          <h:panelGroup rendered="#{usersession.currentUser.librarian}">
            <h:commandButton value="Check In" action="#{bookdisplayform.checkBookIn}"
                rendered="#{bookdisplayform.book.checkedOut}"/>
         </h:panelGroup>

         </h:panelGroup>
     </h:panelGroup>
  </td></tr>
 </table>
 <h:selectBooleanCheckbox onclick="submit()"
                valueChangeListener="#{bookdisplayform.safeModeChange}"/>
 <h:outputText value="Safe Mode"/>
</h:form>

</body>

</f:view>
</html>