JSF gera texto

Java

30/10/2013

pessoal, estou com um exemplo simples, era pra simplesmente apertar o botão e gerar um texto


package controle;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.UIComponent;
import javax.faces.event.ActionEvent;

@ManagedBean(name = "controleComponentes")
@SessionScoped

public class ControleComponentes implements Serializable{
	private String texto;
	private String idComponente;
	
	public ControleComponentes(){
				
	}
	
	public String geraTexto(){
		texto = "Texto gerado: < > & <b>Texto em negrito</b>";
		return "componentesParte2";
	}
	
	public String executar(){
		return "componentesParte3";
	}
	
	public void listener(ActionEvent event){
		UIComponent source = event.getComponent();
		idComponente = source.getId();
	}

	public String getTexto() {
		return texto;
	}

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

	public String getIdComponente() {
		return idComponente;
	}

	public void setIdComponente(String idComponente) {
		this.idComponente = idComponente;
	}
}





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"> 

<h:head><title>Botões, Links e entrada de texto</title></h:head> 
<h:body> 
	<h:form id="formulario">
		<h:commandButton value="Executar"
		 action="#{controleComponentes.executar()}"
		 actionListener="#{controleComponentes.listener}"
		 id="btnEnviar"/>
	</h:form>
	<h:outputText value="#{controleComponentes.idComponente}" />
</h:body> 
</html>

Eduardo Pessoa

Eduardo Pessoa

Curtidas 0

Respostas

Eduardo Pessoa

Eduardo Pessoa

30/10/2013

problema resolvido,

a solução foi atualização no browser.
GOSTEI 0
Eduardo Pessoa

Eduardo Pessoa

30/10/2013

podem fechar, obrigado
GOSTEI 0
POSTAR