Accommodate elements in repeater

1

I am using <ui:repeat> to display the data of a list of an object called DiscountPorWeight, which has 3 attributes:

  • An Object called Service Type

  • An integer called kilograms

  • A double called cost

The code I use to show it in the view is as follows:

<ui:repeat value="#{descuentosCtrl.descuentosPorPeso}" var="descuento">
    <br/>

    #{descuento.tipoServicio.nombre} #{descuento.kilogramos} Kg :
    <p:inputText value="#{descuento.costo}" style="width: 200px;"/>

    <br/>
</ui:repeat>

The way it ends up showing itself is as follows:

However, the way I want it to show is as follows:

But I can not think of how to do it using <ui:repeat>

Does anyone have an idea of how to achieve it?

    
asked by gibran alexis moreno zuñiga 22.03.2017 в 23:16
source

1 answer

1

You should first remove the repeated values from your list List <DescuentoPorPeso>listaLimpia for that you can use collections of the type HashSet that removes duplicates Review link hashSet on your page as an example you could have something like this:

<p:commandButton value="send" action="#{mainController.doProcess()}" update=":f1:aux"/>

<h:panelGroup id="aux">
<ui:repeat var="limpia" value="#{mainController.listaLimpia}" >
                #{limpia.tipoServicio}
                    <ui:repeat var="des" value="#{mainController.des}">
                        <h:panelGroup rendered="#{des.tipoServicio eq limpia.tipoServicio}" id="aux">
                            <p:inputText value="#{des.costo}"/>
                        </h:panelGroup>

                    </ui:repeat>
            <br/>

</ui:repeat>
</h:panelGroup>

This is more a reference that you can take I hope it will be helpful! Remember that the .doProcess() is the method that is responsible for removing duplicates (clean list), in the external repeat runs the List <DescuentoPorPeso> listalimpia while the internal the entire collection of List <DescuentoPorPeso> tu_lista so that in the end only make a comparison in <h:panelGroup rendered="#{des.tipoServicio eq limpia.tipoServicio}"..../>

    
answered by 23.03.2017 в 05:25