Pessoal já procurei e não encontrei,
preciso chamar uma pagina
Hoje tenho um menu lado esquerdo, e quando clicar em um botao deste menu gostaria que chamasse minha pagina dentro do
hoje faz isso mas atualiza toda a pagina.
Estou usando primefaces3.0 + jsf + tomcat7
alguma dica?
<?xml version='1.0' encoding='UTF-8' ?>
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="/layoutAjax/resources/css/default.css" rel="stylesheet" type="text/css" />
<link href="/layoutAjax/resources/css/cssLayout.css" rel="stylesheet" type="text/css" />
<title>Facelets Template</title>
</h:head>
<h:body>
<p:layout fullPage="true" >
<p:layoutUnit id="left" position="west" size="150" resizable="false" closable="true" collapsible="true" header="Menu" minSize="100">
<ui:insert name="esquerda">
</ui:insert>
</p:layoutUnit>
<p:layoutUnit id="center" position="center">
<ui:insert name="centro">
</ui:insert>
</p:layoutUnit>
</p:layout>
</h:body>
</html>
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
template="./templates/templateHome.xhtml">
<ui:define name="esquerda">
<ui:include src="menu.xhtml"/>
</ui:define>
</ui:composition>
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:fragment xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:form id="formMenu">
<h:panelGrid columns="1">
<p:button value="Home" outcome="index"/>
<p:button value="Chama Novo Cliente" title="Clique aqui para adicionar um novo cliente."
outcome="novocliente.xhtml">
</p:button>
<p:button value="Todos"/>
</h:panelGrid>
</h:form>
</ui:fragment>
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
template="./templates/templateHome.xhtml"
xmlns:f="http://java.sun.com/jsf/core">
<ui:define name="esquerda">
<ui:include src="menu.xhtml"/>
</ui:define>
<ui:define name="centro">
<h:form id="formNovoCliente">
<p:panel header="Novo Cadastro" closable="true" rendered="true" id="panelNovoCliente" closeSpeed="0"
widgetVar="novoCliente" footer="Campos com * são obrigatorios.">
<!--<p:messages/>-->
<h:panelGrid columns="3">
<h:outputLabel value="Nome: *" for="nome"/>
<p:inputText id="nome" value="#{beanCliente.nome}" required="true" label="Nome" size="35">
<f:validateLength minimum="8"/>
</p:inputText>
<p:message for="nome"/>
<h:outputLabel value="Telefone: *" for="telefone"/>
<p:inputMask id="telefone" value="#{beanCliente.telefone}" mask="([telefone removido]" required="true" label="Telefone." size="13"/>
<p:message for="telefone"/>
<p:commandButton id="btnSalvar" value="Salvar" update="panelNovoCliente" actionListener="#{beanCliente.pegaCliente()}" onclick="ms();" />
<p:commandButton value="Cancelar" onclick="novoCliente.close();" type="button" />
</h:panelGrid>
</p:panel>
<script>
function ms(){
alert("#{beanCliente.mensagem}");
}
</script>
</h:form>
</ui:define>
</ui:composition>
package bean;
import dao.ClienteDAO;
import java.awt.event.ActionEvent;
import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
@ManagedBean (name="beanCliente")
@RequestScoped //apos requisicao perdese os dados
public class Cliente{
private String nome;
private String telefone;
private String mensagem;
public String getMensagem() {
return mensagem;
}
public void setMensagem(String mensagem) {
this.mensagem = mensagem;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getTelefone() {
return telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
public void Cliente(String nome, String telefone, String mensagem) {
this.nome = nome;
this.telefone = telefone;
this.mensagem = mensagem;
}
public String pegaCliente(){
System.out.println("Nome: "+ nome + "\nTelefone: " + telefone);
ClienteDAO cli = new ClienteDAO();
cli.setNome(nome);
cli.setTelefone(telefone);
Integer a = cli.gravarCliente();
if(a != 0){
mensagem = "Cadastrado com sucesso";
limpaCampos();
}else{
mensagem = "erro";
}
return mensagem;
}
public void limpaCampos(){
nome = "";
telefone = "";
}
}
Nao sei se fiz do modo certo.
Obrigado.