Problem with datatable Selection, and how to access a var outside of the repeat method (primeFaces)

Asked

Viewed 43 times

2

Hello

I have a screen where I list some records through the datatable (primefaces)

1) In my Bean I have two lists one that I feed with the records returned from the bank and the other that will be used by datatable Selection to store the selected items on the screen

@Getter @Setter
private List<RegistrosDTO> listaRegistros;

@Getter @Setter
private List<RegistrosDTO> listaRegistrosSelecionados;

In a second screen I will display the ids of the selected items on the previous screen, for this I am using the repeat function

<ui:repeat value="#{meuBBean.listaRegistrosSelecionados}"                                                                   
           var="registrosSelecionados" 
       varStatus="status">

    <h:panelGroup>
        <h:outputText
            value="#{registro.id}" />
    </h:panelGroup>
</ui:repeat>

The problem here is that you are only displaying the first item in the list, for example:

Selected Records on the first screen: 100, 101

Records displayed on the second screen: 100

2) In addition to displaying the ids of the records that are within the repeat loop, I need the other attributes but those outside the repeat block because they are the same for all ex records.:

var="registrationSelections" varStatus="status">

        <h:panelGroup>
            <h:outputText value="#{registrosSelecionados.id}" />
        </h:panelGroup>
    </ui:repeat>
</h:panelGrid>

 <h:panelGroup>
    <h:outputText value="#{registrosSelecionados.nome}" />
 </h:panelGroup>

The problem here is that I can’t access var=registrationsSelected outside the repeat block, I tried using the datagrid component to have a var visible inside and outside the repeat, but also failed.

Any ideas to help me with this ?

Thanks in advance.

1 answer

1

Hello

I managed to resolve this issue,

1) In the first item the "problem" and that my meuBean.listRegistrosSelections were bringing two equal records (100, 100) and at the time of displaying inside the repeat block it makes a kind of "DISTINCT" and thus displays only one record (100). When the list brings two different records (100,101) they are displayed correctly within the repeat block.

2) The var=registrationsSelections will really only be seen inside the repeat block, and to pick up the die outside the block I was failing to mention the Indice as below:

value="#{meuBBean.listRegistrosSelectionsget(0). name}"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.