title: Java crud edit view
body: <p>I am new to Java and servlets and I have followed this tutorial <a href="https://netbeans.org/kb/docs/web/jsf20-crud.html" rel="nofollow">https://netbeans.org/kb/docs/web/jsf20-crud.html</a>. I am using my own database which includes 2 tables one for users and the other for cars. I need to be able to show the table's contents depending on which cars are available (ie by using an sql command). How can I do this? The current view shows everything.</p>
  
  <p>Also, I need to create a login screen where I check users against the database. How can I execute an sql command from an xhtml page?</p>
  
  <p>The list page is as follows but I need to display the cars which have a certain field ticked. What must I edit?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:f="http://xmlns.jcp.org/jsf/core"&gt;
  
  &lt;ui:composition template="/template.xhtml"&gt;
      &lt;ui:define name="title"&gt;
          &lt;h:outputText value="#{bundle.ListCarsTitle}"&gt;&lt;/h:outputText&gt;
      &lt;/ui:define&gt;
      &lt;ui:define name="body"&gt;
          &lt;h:form styleClass="jsfcrud_list_form"&gt;
              &lt;h:panelGroup id="messagePanel" layout="block"&gt;
                  &lt;h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/&gt;
              &lt;/h:panelGroup&gt;
              &lt;h:outputText escape="false" value="#{bundle.ListCarsEmpty}" rendered="#{carsController.items.rowCount == 0}"/&gt;
              &lt;h:panelGroup rendered="#{carsController.items.rowCount &gt; 0}"&gt;
                  &lt;h:outputText value="#{carsController.pagination.pageFirstItem + 1}..#{carsController.pagination.pageLastItem + 1}/#{carsController.pagination.itemsCount}"/&gt;&amp;nbsp;
                  &lt;h:commandLink action="#{carsController.previous}" value="#{bundle.Previous} #{carsController.pagination.pageSize}" rendered="#{carsController.pagination.hasPreviousPage}"/&gt;&amp;nbsp;
                  &lt;h:commandLink action="#{carsController.next}" value="#{bundle.Next} #{carsController.pagination.pageSize}" rendered="#{carsController.pagination.hasNextPage}"/&gt;&amp;nbsp;
                  &lt;h:dataTable value="#{carsController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px"&gt;
                      &lt;h:column&gt;
                          &lt;f:facet name="header"&gt;
                              &lt;h:outputText value="#{bundle.ListCarsTitle_carId}"/&gt;
                          &lt;/f:facet&gt;
                          &lt;h:outputText value="#{item.carId}"/&gt;
                      &lt;/h:column&gt;
                      &lt;h:column&gt;
                          &lt;f:facet name="header"&gt;
                              &lt;h:outputText value="#{bundle.ListCarsTitle_isRented}"/&gt;
                          &lt;/f:facet&gt;
                          &lt;h:outputText value="#{item.isRented}"/&gt;
                      &lt;/h:column&gt;
                      &lt;h:column&gt;
                          &lt;f:facet name="header"&gt;
                              &lt;h:outputText value="#{bundle.ListCarsTitle_rentalDate}"/&gt;
                          &lt;/f:facet&gt;
                          &lt;h:outputText value="#{item.rentalDate}"&gt;
                              &lt;f:convertDateTime pattern="MM/dd/yyyy" /&gt;
                          &lt;/h:outputText&gt;
                      &lt;/h:column&gt;
                      &lt;h:column&gt;
                          &lt;f:facet name="header"&gt;
                              &lt;h:outputText value="#{bundle.ListCarsTitle_rentedDueDate}"/&gt;
                          &lt;/f:facet&gt;
                          &lt;h:outputText value="#{item.rentedDueDate}"&gt;
                              &lt;f:convertDateTime pattern="MM/dd/yyyy" /&gt;
                          &lt;/h:outputText&gt;
                      &lt;/h:column&gt;
                      &lt;h:column&gt;
                          &lt;f:facet name="header"&gt;
                              &lt;h:outputText value="#{bundle.ListCarsTitle_paid}"/&gt;
                          &lt;/f:facet&gt;
                          &lt;h:outputText value="#{item.paid}"/&gt;
                      &lt;/h:column&gt;
                      &lt;h:column&gt;
                          &lt;f:facet name="header"&gt;
                              &lt;h:outputText value="#{bundle.ListCarsTitle_rentedToUserId}"/&gt;
                          &lt;/f:facet&gt;
                          &lt;h:outputText value="#{item.rentedToUserId}"/&gt;
                      &lt;/h:column&gt;
                      &lt;h:column&gt;
                          &lt;f:facet name="header"&gt;
                              &lt;h:outputText value="&amp;nbsp;"/&gt;
                          &lt;/f:facet&gt;
                          &lt;h:commandLink action="#{carsController.prepareView}" value="#{bundle.ListCarsViewLink}"/&gt;
                          &lt;h:outputText value=" "/&gt;
                          &lt;h:commandLink action="#{carsController.prepareEdit}" value="#{bundle.ListCarsEditLink}"/&gt;
                          &lt;h:outputText value=" "/&gt;
                          &lt;h:commandLink action="#{carsController.destroy}" value="#{bundle.ListCarsDestroyLink}"/&gt;
                      &lt;/h:column&gt;
                  &lt;/h:dataTable&gt;
              &lt;/h:panelGroup&gt;
              &lt;br /&gt;
              &lt;h:commandLink action="#{carsController.prepareCreate}" value="#{bundle.ListCarsCreateLink}"/&gt;
              &lt;br /&gt;
              &lt;br /&gt;
              &lt;h:link outcome="/index" value="#{bundle.ListCarsIndexLink}"/&gt;
          &lt;/h:form&gt;
      &lt;/ui:define&gt;
  &lt;/ui:composition&gt;
  </code></pre>
  
  <p></p>