Formularios list.xhmtl, new.xhtml, view.xhtml

Dentro de Web-Pages creamos la carpeta pages/pais

Aquí crearemos las paginas:

  • list.xhtml

  • view.xhtml

  • new.xhtml

list.xhtml

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"  
        xmlns:p="http://primefaces.org/ui" 
      xmlns:e="http://xmlns.jcp.org/jsf/composite/extensions">

    <f:view contentType="text/html">
        <h:head>
            <f:facet name="first">
                <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
                <title>PrimeFaces</title>
            </f:facet>
        </h:head>

        <h:body>


            <h:form  id="form" prependId="true">
                <p:messages id="messages" showDetail="true" closable="true">
                    <p:autoUpdate />
                </p:messages>

                <p:panel id="content" header="Paises" 
                         footer="Movie Details" style="margin-bottom:20px">





                    <p:outputLabel value="Id"/>
                    <e:autocompletepais listener="#{paisController.handleAutocompleteOfListXhtml}"
                                        value="#{paisController.paisSearch}"
                                        itemLabel=" #{p.idpais}"
                                        field="idpais"
                                        update=" :form:datatable"/>

                    <p:outputLabel value="Pais"/>
                    <e:autocompletepais listener="#{paisController.handleAutocompleteOfListXhtml}"
                                        value="#{paisController.paisSearch}"
                                        itemLabel=" #{p.pais}"
                                        field="pais"
                                        update=" :form:datatable"/>






                    <p:messages  id="msg"/>



                    <p:dataTable value="#{paisController.paisList}"
                                 var="item"
                                 id="datatable"
                                 paginated="false"
                                 onpage="console.log('page');"
                                 >
                        <f:facet name="header">
                            <e:paginator 
                                rowPage="#{paisController.rowPage}"
                                clear="#{paisController.clear()}"
                                first="#{paisController.first()}"
                                back="#{paisController.back()}"
                                next="#{paisController.next()}"
                                last="#{paisController.last()}"
                                page="#{paisController.page}"
                                pages="#{paisController.pages}"
                                skip="ajax:paisController.skip(paisController.page)" 
                                new="#{paisController.prepareGoNew()}"
                                printAll="#{paisController.printAll()}"
                                />

                        </f:facet>
                        <p:column headerText="Cedula">
                            <p:outputLabel value="#{item.idpais}"/>
                        </p:column>
                        <p:column headerText="Nombre">
                            <p:outputLabel value="#{item.pais}"/>
                        </p:column>


                        <p:column>

                            <p:commandButton                 

                                iconAwesome="fa-edit" 
                                value="Editar"
                                title="Editar"
                                immediate="true"

                                action= "#{paisController.prepareView(item)}" 
                                >


                            </p:commandButton>
                        </p:column>

                        <p:column>
                            <p:commandButton                                             
                                icon="fa-trash-o" 
                                value="Eliminar" 
                                process=":form:datatable" 
                                action="#{paisController.delete(item,false)}" 
                                update=":form:datatable, :form:msg" > 

                            </p:commandButton>
                        </p:column>



                    </p:dataTable>

                    <p:commandButton value="new" action="#{paisController.prepareGoNew()}"/>
                    <br></br>
                    <p:commandLink value="index" action="/index"/>
                </p:panel>
            </h:form>


        </h:body>

    </f:view>
</html>

new.xhtml

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html 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">

    <f:view contentType="text/html">
        <h:head>
            <f:facet name="first">
                <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
                <title>PrimeFaces</title>
            </f:facet>
        </h:head>

        <h:body>


            <h:form  id="form" prependId="true">
                <p:messages  id="msg"/>
                <p:panelGrid columns="2">
                    <p:outputLabel value="idpais"/>
                    <p:inputText value="#{paisController.pais.idpais}" required="true"/>
                    <p:outputLabel value="pais"/>
                    <p:inputText value="#{paisController.pais.pais}"  required="true"/>
                  
                </p:panelGrid>
                <p:row>
                    <p:column>
                          <p:commandButton value="save"
                                 action="#{paisController.save}"
                                 update=":form:msg, :form"/>
                    </p:column>
                    <p:column>
                         <p:commandButton value="list" action="#{paisController.prepareGoList()}" immediate="true"/>
                    </p:column>
                   
                </p:row>
              
                
              
            </h:form>

        </h:body>

    </f:view>
</html>

view.xhtml

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html 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">

    <f:view contentType="text/html">
        <h:head>
            <f:facet name="first">
                <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
                <title>PrimeFaces</title>
            </f:facet>
        </h:head>

        <h:body>


            <h:form  id="form" prependId="true">
                <p:messages  id="msg"/>
                <p:panelGrid columns="2">
                    <p:outputLabel value="Idpais"/>
                    <p:inputText value="#{paisController.pais.idpais}" disabled="true" required="true"/>
                    <p:outputLabel value="Pais"/>
                    <p:inputText value="#{paisController.pais.pais}"  required="true"/>

                </p:panelGrid>
                <p:row>
                    <p:column>
                        <p:commandButton value="Editar"
                                         rendered="#{paisController.writable}"
                                         action="#{paisController.edit}"
                                         update=":form:msg, :form"/>
                    </p:column>
                    <p:column>
                        <p:commandButton value="Eliminar"
                                         rendered="#{paisController.writable}"
                                         action="#{paisController.delete(paisController.pais,true)}"
                                         update=":form:msg, :form"/>
                    </p:column>
                    <p:column>
                        <p:commandButton value="list" action="#{paisController.prepareGoList()}" immediate="true"/>
                    </p:column>

                </p:row>



            </h:form>

        </h:body>

    </f:view>
</html>

Last updated

Was this helpful?