Boa noite pessoal.
Tenho um aplicativo em jsf + primefaces chamado acesso. contendo os códigos abaixo:
Bean
@ManagedBean
@SessionScoped
public class AcessoBean implements java.io.Serializable {
private UsuarioDAO usuDAO = new UsuarioDAO();
private RelUsuarioEmpresaDAO relDAO = new RelUsuarioEmpresaDAO();
private AplicativosDAO appDAO = new AplicativosDAO();
public RelUsuarioEmpresa rel = new RelUsuarioEmpresa();
public Usuario usuario = new Usuario();
public Aplicativos aplicativo = new Aplicativos();
public int idApl;
public String usr;
FacesMessage msg = null;
boolean loggedIn = false;
private String logged;
public String carregaBean() {
Logger.getLogger(AcessoBean.class.getName()).log(Level.INFO, "LoginBean.login(): {0}", usr);
//String logged;
RequestContext context = RequestContext.getCurrentInstance();
try {
usuario = usuDAO.getByUsername(usr);
} catch (SQLException ex) {
Logger.getLogger(AcessoBean.class.getName()).log(Level.SEVERE, null, ex);
msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Erro na consulta", "BD");
} catch (ClassNotFoundException ex) {
Logger.getLogger(AcessoBean.class.getName()).log(Level.SEVERE, null, ex);
msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "usuario invalido", "verifique");
}
if (usuario == null) {
loggedIn = false;
msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Login Error: ", "usuario não encontrado!");
} else {
loggedIn = true;
msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Bem vindo! ", usuario.getUsername());
}
Logger.getLogger(AcessoBean.class.getName()).log(Level.INFO, "usuario: {0}", usuario.getUsername());
FacesContext.getCurrentInstance().addMessage(null, msg);
context.addCallbackParam("loggedIn", loggedIn);
return "teste";
}
index.xhtml
<?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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<f:metadata>
<f:viewParam name="usuario" value="#{acessoBean.usr}" />
</f:metadata>
</h:head>
<h:body>
<h:form>
usuario: #{acessoBean.usr}<br/>
<p:commandButton action="#{acessoBean.carregaBean}" value="teste"/>
</h:form>
</h:body>
</html>
teste.xhtml
<?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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
Hello from Facelets <br/>
<h:outputText value="testando login: #{acessoBean.usuario.username}"/> <br/><br/>
</h:body>
</html>
quando chamo o aplicativo pelo link: http://localhost:8081/acesso/?usuario=junior funciona direitinho e consigo navegar da pagina index para a teste sem problemas.
Preciso incluir esta chamada, para abrir em uma frame de um aplicativo pai, conforme abaixo:
index.xhtml do aplicativo pai:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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">
<h:head>
<title>jvmsoftware</title>
</h:head>
<frameset rows="*" cols="230,*" framespacing="1" frameborder="yes" border="1" bordercolor="#666666">
<frame src="faces/frameLeft.xhtml" name="leftFrame" scrolling="yes" noresize="noresize" id="leftFrame" title="leftFrame" />
<frame src="faces/frameMain.xhtml" name="mainFrame" scrolling="yes" noresize="noresize" id="mainFrame" title="mainFrame" />
</frameset>
frameLeft.xhtml do aplicativo pai, que é responsável por fazer a chamada da carga do aplicativo na frame da index:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>frame left</title>
<script type="text/javascript">
function refreshMain(){
parent.frames['mainFrame'].location.reload();
}
function refreshLeft(){
parent.frames['leftFrame'].location.reload();
}
</script>
</h:head>
<h:body style=" font-family: arial; background-color: activeborder">
<div align="center">
<img src="images/jvmsoftware.jpg"/>
</div>
<h:form>
<div align="center">
<p:messages/>
<p:panelGrid style="width: 180px; background-color: activecaption" id="login" columns="1">
<p:outputLabel style="width: 150px; font-size: 10px" for="user" value="usuario:"/>
<p:inputText disabled="true" style="width: 150px; font-size: 10px" id="user" value="#{loginBean.usuario.username}"/>
<p:outputLabel style="width: 150px; font-size: 10px" for="empresa" value="empresa:"/>
<p:inputText disabled="true" style="width: 150px; font-size: 10px" id="empresa" value="#{loginBean.rel.empresa.nomeFantasia}"/>
</p:panelGrid>
</div>
<div align="center">
<p:panelGrid style="width: 180px; background-color: activecaption" id="aplic" columns="1">
<div align="center">
<p:outputLabel style="font-weight: bolder; width: 150px; font-size: 12px" for="ap" value="SELEÇÃO DE APLICATIVO"/>
</div>
<div align="left">
<p:selectOneListbox id="ap" style="font-size: 10px; width: 150px; height: 200px"
value="#{loginBean.selectedAplicativo}" converter="aplicativosConversor">
<f:selectItems var="apl" value="#{loginBean.listAplicativos}" itemValue="#{apl.label}"/>
<p:ajax onstart="confirmation.show()" update="@this"/>
</p:selectOneListbox>
</div>
</p:panelGrid>
</div>
<p:confirmDialog closable="false" id="confirmDialog" message="Ao mudar de aplicativo todos os dados não salvos serão perdidos. Deseja realmente mudar o aplicativo?"
header="Alteração de Aplicativo" severity="alert" widgetVar="confirmation">
<p:commandButton onsuccess="refreshMain()" id="confirm" value="OK"
actionListener="#{loginBean.trocaAplicativo}" oncomplete="confirmation.hide()"/>
<p:commandButton onsuccess="refreshLeft()" id="decline" value="Cancelar"
actionListener="#{loginBean.mantemAplicativo}" oncomplete="confirmation.hide()"/>
</p:confirmDialog>
</h:form>
</h:body>
</html>
O problema, é que quando carrego o aplicativo filho dentro da frame do aplicativo pai, ele carrega a index do filho certinho, mas não consigo navegar no aplicativo filho (ir para a pagina teste.xhtml).
Alguem consegue ajudar?