Tab do richfaces: Dados somem após mudar de aba

2 respostas
dudamel

Olá Pessoal,

Saberiam me dizer por que os dados somem, quando mudou de uma aba para outra. Quando submeto o form, na primeira aba o valor do atributo é exibido, porém, ao mudar para outra aba, o atributo some, ficando vazio.

OBS: É um exemlo tosco, mas é pq estou começando a mexer agora com JSF. :slight_smile:

Index

<%@ taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<f:view>
	<h:form>
		<h:panelGrid columns="1">
			<h:messages showDetail="false" showSummary="true" layout="table" />
			<h:column>
				<h:outputLabel value="Palavra" for="txtPalavra" />: 
				<h:inputText id="txtPalavra" value="#{palavra.texto}"
					required="true" requiredMessage="Favor informar uma palavra" />
			</h:column>
		</h:panelGrid>
		<h:commandButton value="Login" action="#{palavra.atribuir}" />
	</h:form>
</f:view>

Página com abas

<%@ taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<f:view>
	<h:form id="form1">
		<rich:tabPanel switchType="ajax">
			<rich:tab label="Palavra">
					Olá, <b><h:outputLabel value="#{palavra.texto}" /></b>!!!
		</rich:tab>
			<rich:tab label="Quantidade de Letras">
				O nome possui <strong><h:outputLabel
					value="#{palavra.qtdeLetras}" /></strong> letras.
		</rich:tab>
			<rich:tab label="Primeira letra">
				A letra inicial é <strong><h:outputLabel
					value="#{palavra.letraInicial}" /></strong>
			</rich:tab>
		</rich:tabPanel>
	</h:form>
	<br>
</f:view>

Bean

package beans;

public class Palavra {

	private String texto;
	private char letraInicial;
	private int qtdeLetras;
	
	public String getTexto() {
		return texto;
	}

	public void setTexto(String texto) {
		this.texto = texto;
	}

	public char getLetraInicial() {
		return letraInicial;
	}

	public void setLetraInicial(char letraInicial) {
		this.letraInicial = letraInicial;
	}

	public int getQtdeLetras() {
		return qtdeLetras;
	}

	public void setQtdeLetras(int qtdeLetras) {
		this.qtdeLetras = qtdeLetras;
	}

	public Palavra(){
		
	}
	
	public String atribuir(){
		this.setTexto(texto);
		this.setQtdeLetras(texto.length());
		this.setLetraInicial(texto.charAt(0));
		return "listaPalavra";
	}
}

No faces-config.xml, o escopo está como request para o bean Palavra.

Alguma idéia pessoal?

ABraços!

Eduardo

2 Respostas

themasta

tb estou iniciando com richfaces :smiley:

tenta mudar o escopo do managed bean pra session ao inves de request

imagino q seja pq qd vc clica na tab a requisicao é outra e o dado some

flw

dudamel

Olá themasta ,

Valeu pela resposta. Realmente, se por exemplo alterar para application, aí os dados continuam. Será que esta realmente é a única maneira daí?

Mesmo assim, valeu pela resposta =]]

Abraços!

Criado 19 de novembro de 2007
Ultima resposta 20 de nov. de 2007
Respostas 2
Participantes 2