Primefaces tooltip with image and table filter

Asked

Viewed 238 times

1

Hello

I have the following situation: a table of users, and users have photos, I would like to hover over the user name, present a tooltip of the first faces with the user image, which is already happening.

The problem arises when we filter the table data, after filtering the image no longer appears.

Remarks:

  • The image is being inserted through a Streamedcontent object.
  • So I researched some people are reporting having problems with the filter being set null, so when filtering, loses the reference of the data, even so I could not solve the problem, follows the link of the possible problem: http:/forum.primefaces.org/viewtopic.php? f=3&t=44524

Even following the steps mentioned, it did not work for me, however I believe that this is the problem.

Any help is welcome.

Imagem exemplificando o problema

<p:dataTable id="tableUsers" var="userTable" value="#{usersController.listUsers}" selection="#{usersController.selectedUsers}" filteredValue="#{usersController.filteredUsers}" rowKey="#{userTable.id}">
  
  <p:ajax event="filter" listener="#{usersController.onFilterTable}" />

  <p:column headerText="ID" sortBy="#{userTable.id}" filterBy="#{userTable.id}" filterMatchMode="exact">
    <h:outputText value="#{userTable.id}" />
  </p:column>

  <p:column headerText="Nome" sortBy="#{userTable.name}" filterBy="#{userTable.name}" filterMatchMode="contains">
    <h:outputLink id="content" value="#" style="text-decoration:none;">
      <h:outputText value="#{userTable.name}" style="z-index:1;" />
    </h:outputLink>
    <p:tooltip id="toolTipContent" for="content" position="bottom">
      <p:graphicImage id="imageThumbnail" cache="false" rendered="#{userTable.imageStreamed != null}" value="#{userTable.imageStreamed}" width="80" height="80" stream="false" />
      <h:outputText rendered="#{userTable.imageStreamed == null}" value="Sem foto" />
    </p:tooltip>
  </p:column>

</p:dataTable>

When filtering the table

public void onFilterTable(FilterEvent filterEvent) {
  System.out.println("Dados da pesquisa (filtro):");
  Set < String > keys = filterEvent.getFilters().keySet();
  for (String key: keys)
    System.out.println("Chave: " + key + " - Valor: " + filterEvent.getFilters().get(key));

  System.out.println("");
  List < Users > listFilteredUsers = (List < Users > ) filterEvent.getData();
  System.out.println("Lista de Usuários Filtrados: " + listFilteredUsers);
  if (listFilteredUsers != null)
    for (Users user: listFilteredUsers)
      System.out.println(user.getName() + " - StreamedContent: " + user.getImageStreamed());

  System.out.println("=================================================================");
  System.out.println("");
}

With the above code I get the following on the console

Console

As you can notice, the first query returns null (I don’t know why, because it is a valid query, and on the screen returns the data normally, only in Java that does not)

After this first null, all other data is returned but always delayed, for example, when a search is done that should return two users, returns nothing, when I do another search, returns the data from the previous one and so on, but this only in Java, on the screen the search works normally (I did not understand this, in the back-end the event filter returns me something and on the screen happens another).

  • The value of userTable.imageStreamed changes or remains the same ?

  • It remains, but in arrears, I will explain better in question.

No answers

Browser other questions tagged

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