# list.xhtml

Estos formularios los usamos para mostrar todos los registros que estan en la colección.

Tomamos como referencia el formulario form.xhtml lo copiamos y trabajamos sobre el.

Utiliza autocomplete con services.

## ![](https://1998810595-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6NlSdMpuhIAMG0%2F-Lc1WgY0JLeRbCpPFKLC%2F-Lc1WkejUiKE9oBYURSS%2Flistbodega.png?generation=1554820572885981\&alt=media)

## CODIGO COMPLETO

```
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/template.xhtml"
                xmlns:avbravo="http://xmlns.jcp.org/jsf/composite/avbravo"
                xmlns:jsf="http://xmlns.jcp.org/jsf"
                xmlns:b="http://bootsfaces.net/ui">
    <ui:define name="head">

    </ui:define>   
    <ui:define name="title">#{msg['titlelist.bodega']}</ui:define>

    <ui:define name="viewname">#{msg['titlelist.bodega']}</ui:define>


    <ui:define name="content">   
        <!--<f:event listener="#{bodegaController.preRenderView('preRenderView')}" type="preRenderView"/>-->

        <h:form id="form" rendered="#{loginController.loggedIn and applicationMenu.bodega.list}" onkeypress="if (event.keyCode == 13) {
                    return false;
                }">   
            <h:panelGroup id="content" layout="block"> 
                <p:messages id="msgs" autoUpdate="true" closable="true"/>
                <p:remoteCommand  update=":form:content"
                                  name="remoteshowall" />

                <div class="ui-g ui-fluid">
                    <div class="ui-g-12 ui-lg-12">
                        <!-- Left Side -->


                        <div class="card card-w-title">
                            <h1>#{msg['titlelist.bodega']}</h1>


                            <!--<p:panelGrid columns="4" styleClass="form-group ui-panelgrid-blank" layout="grid">-->
                            <p:panelGrid columns="4" columnClasses="ui-grid-col-2,ui-grid-col-4,ui-grid-col-2,ui-grid-col-4" layout="grid" styleClass="ui-panelgrid-blank form-group" style="border:0px none; background-color:transparent;">     
                                <p:outputLabel value="#{app['info.by']} #{msg['field.idbodega']}"/>
                                <p:autoComplete  scrollHeight="250"   dropdown="false"   
                                                 emptyMessage="#{app['info.nohayregistros']}"                                               
                                                 value="#{bodegaController.bodegaSelected}"  
                                                 completeMethod="#{bodegaController.bodegaServices.complete}"  
                                                 var="p"
                                                 itemLabel="#{p.idbodega} "
                                                 itemValue="#{p}" forceSelection="true"> 
                                    <f:converter binding="#{bodegaConverter}"/>
                                    <f:attribute name="field" value="idbodega" />
                                    <p:ajax event="itemSelect" listener="#{bodegaController.handleSelect}"
                                            update=" :form:msgs,:form:dataTable" />  
                                    <f:facet name="itemtip">
                                        <h:panelGrid columns="1" cellpadding="5">
                                            <h:outputText value="#{msg['field.idbodega']} #{p.idbodega}" />


                                        </h:panelGrid>
                                    </f:facet>
                                </p:autoComplete>


                                <p:outputLabel  value="#{app['info.by']} #{msg['field.direccion']}"/>
                                <p:autoComplete  scrollHeight="250"   dropdown="false"    
                                                 emptyMessage="#{app['info.nohayregistros']}" 
                                                  value="#{bodegaController.bodegaSelected}"  
                                                 completeMethod="#{bodegaController.bodegaServices.complete}"  
                                                 var="p"
                                                 itemLabel="#{p.direccion} "
                                                 itemValue="#{p}" forceSelection="true"> 
                                    <f:converter binding="#{bodegaConverter}"/>
                                            <f:attribute name="field" value="direccion" />
                                    <p:ajax event="itemSelect" listener="#{bodegaController.handleSelect}"
                                            update=" :form:msgs,:form:dataTable" />  
                                    <f:facet name="itemtip">
                                        <h:panelGrid columns="1" cellpadding="5">

                                            <h:outputText value="#{msg['field.bodega']} #{p.direccion}" />


                                        </h:panelGrid>
                                    </f:facet>
                                </p:autoComplete> 




                            </p:panelGrid>


                            <p:dataTable id="dataTable" var="item" 
                                         value="#{bodegaController.bodegaDataModel}"
                                         selectionMode="single" 
                                         widgetVar="widgetDataTable"
                                         selection="#{bodegaController.bodegaSelected}"
                                         filteredValue="#{bodegaController.bodegaFiltered}"
                                         rowKey="#{item.idbodega}"
                                         rows="25" 

                                         emptyMessage="#{app['info.datatableempty']}" reflow="true">

                                <f:facet name="header">

                                    <p:outputPanel>
                                        <avbravo:panelDatatable
                                            first="#{bodegaController.first()}"
                                            back="#{bodegaController.back()}"
                                            next="#{bodegaController.next()}"
                                            last="#{bodegaController.last()}"
                                            page="#{bodegaController.page}"
                                            pages="#{bodegaController.pages}"
                                            listener="#{bodegaController.skip(bodegaController.page)}"
                                            new="#{bodegaController.prepare('gonew',bodegaController.bodega)}"
                                            printAll="#{bodegaController.printAll()}"
                                            />

                                    </p:outputPanel>
                                </f:facet>


                                <p:column headerText="#{msg['field.idbodega']}" filterBy="#{item.idbodega}" style="color: #000000; width:150px;text-align: center"
                                          sortBy="#{item.idbodega}"  filterMatchMode="contains" >
                                    <h:outputText value="#{item.idbodega}" />
                                </p:column>


                                <p:column headerText="#{msg['field.direccion']}" 
                                          sortBy="#{item.direccion}"  filterMatchMode="contains" >
                                    <h:outputText value="#{item.direccion}" />
                                </p:column>

                                <p:column headerText="#{msg['field.telefono']}" style="width:150px;text-align: center"
                                          sortBy="#{item.telefono}"  >
                                    <h:outputText value="#{item.telefono}" />
                                </p:column>

                                <p:column headerText="#{msg['field.activo']}" style="width:60px;text-align: center" 
                                          sortBy="#{item.activo}"  filterMatchMode="contains" >
                                    <h:outputText value="#{item.activo}" />
                                </p:column>

                                <p:column style="width:80px;text-align: center" >
                                    <avbravo:columnButton
                                        param="idbodega"
                                        itemid="#{item.idbodega}"
                                        edit="#{bodegaController.prepare('edit',item)}"
                                        delete="#{bodegaController.delete(item,false)}"
                                        rendered="#{applicationMenu.bodega.delete}"
                                        />
                                </p:column>

                            </p:dataTable>
                        </div>
                    </div>
                </div>
                <p:confirmDialog  global="true" showEffect="fade" hideEffect="explode">
                    <p:commandButton  class="btnn btnn-primary" value="#{app['button.yes']}" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
                    <p:commandButton class="btnn btnn-primary" value="#{app['button.no']}" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
                </p:confirmDialog>
            </h:panelGroup>
        </h:form>

        <avbravo:accesodenegado renderedcondition="#{!loginController.loggedIn or !applicationMenu.bodega.list}" />

    </ui:define>

</ui:composition>
```
