Problemas na filterBy do primefaces

Ola, estou com um problema na hora de pegar os dados da minha linha selecionada na dataTable.

Tenho um botão de editar em cada linha, quando clico dou um show em uma dialog que me tras as combos com os dados preenchidos, o problema é que se eu fizer uma busca e clicar no btn de editar esta me mostrando o ultimo registro que cliquei antes de efetuar a busca.

Segue codigos:

user.xhtml

<p:dataTable id="tabela_user" var="user" value="#{userController.listarUsers}" rows="20" paginator="true"
							emptyMessage="Nenhum registro encontrado">
							
								<p:column sortBy="#{user.name}" filterBy="#{user.name}">
									<f:facet name="header">
										<h:outputText value="Nome" />
									</f:facet>
									<h:outputText value="#{user.name}" />
								</p:column>
								<p:column sortBy="#{user.login}" filterBy="#{user.login}">
									<f:facet name="header">
										<h:outputText value="Login" />
									</f:facet>
									<h:outputText value="#{user.login}" />
								</p:column>
								<p:column>
									<p:commandButton
										actionListener="#{userController.prepararAlterarUser}"
										image="ui-icon-pencil" update="infosUser"
										oncomplete="dialogGerUser.show()" />
									<p:commandButton
										actionListener="#{userController.deleteUser}"
										image="ui-icon-trash" />
								</p:column>
							</p:dataTable>

UserController.java

@ManagedBean
@SessionScoped
public class UserController implements Serializable {

	private User user;
	private DataModel listaUsers;

	public DataModel getListarUsers() throws Exception {
		List<User> lista = new UserDaoImp().list();
		listaUsers = new ListDataModel(lista);
		return listaUsers;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public void prepararAdicionarUser(ActionEvent actionEvent) {
		user = new User();
	}

	public void prepararLoginUser(ActionEvent actionEvent) {
		user = new User();
	}

	public void prepararAlterarUser(ActionEvent actionEvent) {
		user = (User) (listaUsers.getRowData());
	}
}

UserDaoImp.java

public class UserDaoImp implements UserDao{
	public UserDaoImp() throws Exception{
	}

	public List<User> list(){
             Session session = HibernateUtil.getSessionFactory().openSession();
             Transaction t = session.beginTransaction();
             List lista = session.createQuery("from User order by name").list();
             t.commit();
             return lista;
	}
        ............
}

Espero ter ajuda de vocês

Aguardo

é isso mesmo que deveria acontecer kkk.
Para que isso funcione, você tem que trabalhar de 2 formas, com o select do datatable realizando a função EM CIMA da linha, ou colocando um f:setPropertyActionListener com o id da linha que foi criada para ser capturada no momento em que for clicada:

vou colocar o código do exemplo aqui, mas você pode estar acessando ele no showcase do primefaces: http://www.primefaces.org/showcase/ui/datatableRowSelectionByColumn.jsf

&lt;h:form id="form"&gt;  
  
    &lt;p:growl id="msgs" showDetail="true" /&gt;  
  
    &lt;p:dataTable id="cars" var="car" value="#{tableBean.carsSmall}" tableStyle="width:auto"&gt;  
  
        &lt;p:column headerText="Model" style="width:100px"&gt;  
            &lt;h:outputText value="#{car.model}" /&gt;  
        &lt;/p:column&gt;  
  
        &lt;p:column headerText="Year" style="width:100px"&gt;  
            &lt;h:outputText value="#{car.year}" /&gt;  
        &lt;/p:column&gt;  
  
        &lt;p:column headerText="Manufacturer" style="width:100px"&gt;  
            &lt;h:outputText value="#{car.manufacturer}" /&gt;  
        &lt;/p:column&gt;  
  
        &lt;p:column headerText="Color" style="width:100px"&gt;  
            &lt;h:outputText value="#{car.color}" /&gt;  
        &lt;/p:column&gt;  
  
        &lt;p:column style="width:40px"&gt;  
             &lt;h:panelGrid columns="3" styleClass="actions" cellpadding="2"&gt;  
                 &lt;p:commandButton id="selectButton" update=":form:display" oncomplete="carDialog.show()" icon="ui-icon-search" title="View"&gt;  
                     &lt;f:setPropertyActionListener value="#{car}" target="#{tableBean.selectedCar}" /&gt;  
                 &lt;/p:commandButton&gt;  
             &lt;/h:panelGrid&gt;  
        &lt;/p:column&gt;  
  
    &lt;/p:dataTable&gt;  
  
    &lt;p:dialog header="Car Detail" widgetVar="carDialog" resizable="false" id="carDlg"  
                showEffect="fade" hideEffect="explode" modal="true"&gt;  
  
        &lt;h:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;"&gt;  
  
            &lt;f:facet name="header"&gt;  
                &lt;p:graphicImage value="/images/cars/#{tableBean.selectedCar.manufacturer}.jpg"/&gt;  
            &lt;/f:facet&gt;  
  
            &lt;h:outputText value="Model:" /&gt;  
            &lt;h:outputText value="#{tableBean.selectedCar.model}" style="font-weight:bold"/&gt;  
  
            &lt;h:outputText value="Year:" /&gt;  
            &lt;h:outputText value="#{tableBean.selectedCar.year}" style="font-weight:bold"/&gt;  
  
  
            &lt;h:outputText value="Manufacturer:" /&gt;  
            &lt;h:outputText value="#{tableBean.selectedCar.manufacturer}" style="font-weight:bold"/&gt;  
  
            &lt;h:outputText value="Color:" /&gt;  
            &lt;h:outputText value="#{tableBean.selectedCar.color}" style="font-weight:bold"/&gt;  
  
        &lt;/h:panelGrid&gt;  
  
    &lt;/p:dialog&gt;  
  
&lt;/h:form&gt; 
package org.primefaces.examples.view;  
  
import java.io.Serializable;  
import java.util.ArrayList;  
import java.util.Date;  
import java.util.List;  
import java.util.UUID;  
  
import org.primefaces.examples.domain.Car;  
  
public class TableBean {  
  
    static {  
        colors = new String[10];  
        colors[0] = "Black";  
        colors[1] = "White";  
        colors[2] = "Green";  
        colors[3] = "Red";  
        colors[4] = "Blue";  
        colors[5] = "Orange";  
        colors[6] = "Silver";  
        colors[7] = "Yellow";  
        colors[8] = "Brown";  
        colors[9] = "Maroon";  
  
        manufacturers = new String[10];  
        manufacturers[0] = "Mercedes";  
        manufacturers[1] = "BMW";  
        manufacturers[2] = "Volvo";  
        manufacturers[3] = "Audi";  
        manufacturers[4] = "Renault";  
        manufacturers[5] = "Opel";  
        manufacturers[6] = "Volkswagen";  
        manufacturers[7] = "Chrysler";  
        manufacturers[8] = "Ferrari";  
        manufacturers[9] = "Ford";  
    }  
  
    private final static String[] colors;  
  
    private final static String[] manufacturers;  
  
    private List&lt;Car&gt; cars;  
  
    private Car selectedCar;  
  
    public TableBean() {  
        cars = new ArrayList&lt;Car&gt;();  
  
        populateRandomCars(cars, 50);  
    }  
  
    private void populateRandomCars(List&lt;Car&gt; list, int size) {  
        for(int i = 0 ; i &lt; size ; i++)  
            list.add(new Car(getRandomModel(), getRandomYear(), getRandomManufacturer(), getRandomColor()));  
    }  
  
    public Car getSelectedCar() {  
        return selectedCar;  
    }  
    public void setSelectedCar(Car selectedCar) {  
        this.selectedCar = selectedCar;  
    }  
  
    public List&lt;Car&gt; getCars() {  
        return cars;  
    }  
  
    private int getRandomYear() {  
        return (int) (Math.random() * 50 + 1960);  
    }  
  
    private String getRandomColor() {  
        return colors[(int) (Math.random() * 10)];  
    }  
  
    private String getRandomManufacturer() {  
        return manufacturers[(int) (Math.random() * 10)];  
    }  
  
    private String getRandomModel() {  
        return UUID.randomUUID().toString().substring(0, 8);  
    }  
}

vamos esperar que isso te ilumine :smiley:
se você não conseguir ou se der algum problema na função, posta aí

Fiz a alteração seguindo o exemplo fiz vários testes mas ainda tenho um problema, talvez esteja esquecendo algo.

Quando clico no botão para alterar esta entrando no setSelectedUser e setando a variável perfeitamente, mas, quando a dialog aparece vem tudo em branco.

Criei dentro do meu controller o selectedUser

        private User selectedUser;

	public User getSelectedUser() {
		return selectedUser;
	}

	public void setSelectedUser(User selectedUser) {
		this.selectedUser = selectedUser;
	}

No xhtml fiz a alteração

                <p:column>
			<p:commandButton id="selectButton" update=":form:display" oncomplete="dialogGerUser.show()" image="ui-icon-pencil" title="View">
			<f:setPropertyActionListener value="#{user}" target="#{userController.selectedUser}" />
			</p:commandButton>
		</p:column>

e…

	<p:dialog header="Gerencia de Usários" widgetVar="dialogGerUser" resizable="false" modal="true" showEffect="slide" width="500">
		<h:form prependId="false">
			<h:panelGrid id="infosUser" columns="2" style="margin-bottom:10px">

				<h:outputLabel for="name" value="Nome:" />
				<h:inputText id="name" value="#{selectedUser.name}" />

				<h:outputLabel for="login" value="Login:" />
				<h:inputText id="login" value="#{selectedUser.login}" />

				<h:outputLabel for="pass" value="Password:" />
				<h:inputSecret id="pass" value="#{selectedUser.pass}" />

				<p:commandButton update="tabela_user" oncomplete="dialogGerUser.hide();" actionListener="#{userController.adicionarUser}" value="Inserir" />
				<p:commandButton update="tabela_user" oncomplete="dialogGerUser.hide();" actionListener="#{userController.alterarUser}" value="Alterar" />

			</h:panelGrid>
		</h:form>
	</p:dialog>

Alguém enxerga o que ainda estou esquecendo?

Aguardo

eita