Is it possible to display certain data?

0

In the code that I'm going to leave, I show all the records of the offer table, now, is it possible to show only the registered offers on a given day, for example? I had thought of making another table with those recorded data and display the records of that table, but it may be possible to show them through the same table. I leave the code:

<body>

    <ui:composition template="./WEB-INF/Template.xhtml">

         <ui:define name="content">
            <h:outputText value="Total de ofertas:#{ofertasFacadeREST.countREST()}
          "/>

<h:form>
    <h1><h:outputText value="Lista de ofertas disponibles"/></h1>

    <p:dataTable value="#{ofertasFacadeREST.findAll()}" var="item">
         <p:column>
            <f:facet name="header">
                <h:outputText value="Id"/>
            </f:facet>
            <h:outputText value="#{item.id}"/>
        </p:column>
        <p:column>
            <f:facet name="header">
                <h:outputText value="Nombre"/>
            </f:facet>
            <h:outputText value="#{item.nombre}"/>
        </p:column>
        <p:column>
            <f:facet name="header">
                <h:outputText value="Descripción"/>
            </f:facet>
            <h:outputText value="#{item.descripcion}"/>
        </p:column>

         <p:column>
            <f:facet name="header">
                <h:outputText value="Fecha de incorporación"/>
            </f:facet>
            <h:outputText value="#{item.fecha_Insc}"/>
        </p:column>

          <p:column>
            <f:facet name="header">
                <h:outputText value="Puesto de trabajo"/>
            </f:facet>
            <h:outputText value="#{item.puesto}"/>
        </p:column>



          <p:column>
            <f:facet name="header">
                <h:outputText value="Requisitos"/>
            </f:facet>
            <h:outputText value="#{item.requisitos}"/>
        </p:column>


    </p:dataTable>
</h:form>

      

    
asked by Iskandarina 18.05.2018 в 18:26
source

1 answer

0

Yes, it is possible. Primefaces gives you ways to filter, with algorithms already provided by the Framework or allowing you to create a filter custom .

For your case you could create a method in your backing bean to be able to filter the offers.

<p:column filterFunction="#{tuBackingBean.filtrarPorFecha}">
    <f:facet name="header">
        <h:outputText value="Fecha de incorporación"/>
    </f:facet>
    <h:outputText value="#{item.fecha_Insc}"/>
</p:column>

On the side of your Backing bean you will need to implement the method filtrarPorFecha

public boolean filtrarPorFecha(Object value, Object filter, Locale locale) {
//value es el que viene en la columna de tu datable
//filter es la fecha que ingresa el usuario para filtrar
//locale es opcional y lo podes usar o no segun el caso

//debes retornas true si el valor de la columna es aceptado por el filtro
//o false si no, o sea, si el filtro lo deja afuera       
}

On the other hand, some recommendations. Your backing bean should not have business logic, but presentation. And keep in mind that JSF is a server-oriented framework, very few things are solved on the client side. Invocations to the rest service that you apparently invoke should be encapsulated in a service layer. And the bean backing should invoke this service in order to arm the screen.

    
answered by 23.05.2018 / 17:55
source