JSF - DataModel.getRowData() sempre retorna o mesmo registro

4 respostas
V

Olá senhores,

meu rich:dataTable está funcionando, mas quando tento exibir um registro selecionado pelo usuário utilizando o método citado sempre obtenho o mesmo registro. Procurei saber se ele sempre pegava o registro por estar na último posição do datamodel mas não é…

Tentei colocar dentro do link um: <a4j:ajaxListener type=“org.ajax4jsf.ajax.ForceRender”/>
mas também não obitive sucesso…

Agradeço desde já.

public String abrirDados(){
		fncnr = (Fncnr)model.getRowData();
		
		atualizando = true;
		
		return ConstantesUtil.ABRIR_DADOS_FUNCIONARIO;
	}
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib prefix="rich" uri="http://richfaces.org/rich"%>
<%@ taglib prefix="a4j" uri="http://richfaces.org/a4j"%>

<html>
	<head>   
		<title>SICOOP - Sistema de Controle Operacional</title>
		<link type="text/css" rel="stylesheet" href="../../styles/style.css"/>
		<script type="text/javascript" src="../../js/fechar.js"></script>
	</head>
	<body>
		<div id="divContainer">
			<f:view>
				<h:form>
					<rich:panel styleClass="panel">
						<f:facet name="header">
							<h:outputText value="Pesquisa de funcionários"/>
						</f:facet>
						<h:panelGrid width="97%">
							<rich:dataTable id="funcionarioList" value="#{funcionario.listaFuncionarios}" var="func" rows="10" width="100%" 
								onRowMouseOver="this.style.backgroundColor='#F1F1F1'" 
								onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
								<f:facet name="header">
									<rich:columnGroup>
										<rich:column>
											<h:outputText value="Nome"/>
										</rich:column>
										<rich:column>
											<h:outputText value="Cargo"/>
										</rich:column>
										<rich:column>
											<h:outputText value="Chefe equipe" />
										</rich:column>
										<rich:column>
											<h:outputText value="Operador" />
										</rich:column>
										<rich:column>
											<h:outputText value="Situação" />
										</rich:column>
									</rich:columnGroup>
								</f:facet>
								<rich:column filterBy="#{func.nmFncr}" filterEvent="onkeyup" sortBy="#{func.nmFncr}" width="60%">
									<f:facet name="header">
										<h:outputText value="" title=""/>
									</f:facet>
									<h:commandLink action="#{funcionario.abrirDados}" value="#{func.nmFncr}"/>
								</rich:column>
								<rich:column filterBy="#{func.crg.nmCrg}" filterEvent="onkeyup" sortBy="#{func.crg.nmCrg}" width="10%">
									<h:outputText value="#{func.crg.nmCrg}"/>
								</rich:column>
								<rich:column filterBy="#{func.inChfEqp}" filterEvent="onkeyup" sortBy="#{func.inChfEqp}" width="10%">
									<h:outputText rendered="#{func.inChfEqp == 'S'}" value="Sim"/>
									<h:outputText rendered="#{func.inChfEqp == 'N'}" value="Não"/>
								</rich:column>
								<rich:column filterBy="#{func.inOpr}" filterEvent="onkeyup" sortBy="#{func.inOpr}" width="10%">
									<h:outputText rendered="#{func.inOpr == 'S'}" value="Sim"/>
									<h:outputText rendered="#{func.inOpr == 'N'}" value="Não"/>
								</rich:column>
								<rich:column filterBy="#{func.stcoFncr.dscrStcoFncr}" filterEvent="onkeyup" sortBy="#{func.stcoFncr.dscrStcoFncr}" width="10%">
									<h:outputText value="#{func.stcoFncr.dscrStcoFncr}"/>
								</rich:column>
							</rich:dataTable>
							<rich:datascroller align="center" for="funcionarioList"/>
							
							<rich:toolBar style="width: 100%; text-align: center;">
									<h:commandButton id="btnNovo" value="Novo" action="#{funcionario.abrirNovo}" immediate="true" styleClass="btn"/>
									<h:commandButton id="btnFechar" value="Fechar" immediate="true" onclick="fechar();" styleClass="btn"/>
							</rich:toolBar>
						</h:panelGrid>
					</rich:panel>
				</h:form>
			</f:view>
		</div>
	</body>
</html>

4 Respostas

javax.skol

Veja se o fncnr foi inicializado.
new Fncnr();
Pode ser isso

rponte

Talvez isso possa te ajudar, é uma thread na lista de discussão do JavaSF,
http://groups.google.com/group/javasf/browse_thread/thread/accc404b96d46771?hl=pt-BR

Abraços e boa sorte.

V

é um bug né… eu estava pegando via request mas ai tinha visto esta forma e achei melhor…

vou fazer como especificado pelo pessoal lá, creio que não tem erro…

muito obrigado pela ajuda, vlw mesmo…

S

oi vinicius.rabelo

De qual bug se refere ?

Criado 25 de abril de 2008
Ultima resposta 7 de nov. de 2010
Respostas 4
Participantes 4