Boa noite pessoal.
Tenho o seguinte cenário: Uma pagina index, que é um template de exibição de duas divisões: a do lado esquerdo carrega o logo da empresa e alguns dados do usuário; a do lado direito é a principal e carrega o menu e a aplicação propriamente dita. Se coloco esta pagina como pagina inicial do projeto, ela é aberta normalmente e carrega todos os conteúdos e componestes.
O problema começa, no meu formulário de login, construido com primefaces e javascript. Ao confirmar o login, a index é chamada por um método window.open, no entanto, ela carrega somente a formatação css, mas não carrega o conteúdo.
Vejam os códigos abaixo:
index.xhtml:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JVMSOFTWARE</title>
<style type="text/css">
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
padding-left: 10px;
padding-right: 10px;
}
.twoColFixLt #container {
width: 1070px; /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
background: #FFFFFF;
border: 1px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
padding-top: 0;
}
.twoColFixLt #sidebar1 {
float: left; /* since this element is floated, a width must be given */
width: 190px; /* the actual width of this div, in standards-compliant browsers, or standards mode in Internet Explorer will include the padding and border in addition to the width */
background: #EBEBEB; /* the background color will be displayed for the length of the content in the column, but no further */
border: 1px solid #000000;
padding-top: 0;
}
.twoColFixLt #mainContent {
background: #EBEBEB;
border: 1px solid #000000;
float: right;
width: 870px;
}
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 2px;
}
.fltlft { /* this class can be used to float an element left in your page */
float: left;
margin-right: 2px;
}
.clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
.twoColFixLt #sidebar1 { padding-top: 5px; }
.twoColFixLt #mainContent { zoom: 1; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
</head>
<body class="twoColFixLt">
<div id="container">
<div align="center" id="sidebar1">
<ui:include src="/frameLeft.xhtml"/>
</div>
<div id="mainContent">
<ui:include src="/frameMain.xhtml"/>
<br/><br/><br/><br/>
</div>
<br class="clearfloat"/>
</div>
</body>
</html>
dialogLogin.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:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
</h:head>
<body background="http://localhost:8080/login/images/tecnologia.jpg" value="javascript:void(0)" onload="dlg.show()" title="login">
<p:growl id="growl" showDetail="true" life="3000" />
<p:dialog id="dialog" header="Login" widgetVar="dlg">
<h:form>
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="username" value="Username:" />
<p:inputText value="#{loginBean.username}"
id="username" required="true" label="username" />
<h:outputLabel for="password" value="Password:" />
<h:inputSecret value="#{loginBean.password}"
id="password" required="true" label="password" />
<f:facet name="footer">
<p:commandButton id="loginButton" value="Login" update=":growl"
actionListener="#{loginBean.login}"
oncomplete="handleLoginRequest(xhr, status, args)"/>
</f:facet>
</h:panelGrid>
</h:form>
</p:dialog>
</body>
<script type="text/javascript">
function handleLoginRequest(xhr, status, args) {
if(args.validationFailed || !args.loggedIn) {
jQuery('#dialog').effect("shake", { times:3 }, 100);
} else {
dlg.hide();
jQuery('#loginLink').fadeOut();
window.open('index.xhtml');
}
}
</script>
</html>
LoginBean:
package br.com.jvmsoftware.login.bean;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import org.primefaces.context.RequestContext;
/**
*
* @author user
*/
@ManagedBean
@RequestScoped
public class LoginBean {
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void login() {
RequestContext context = RequestContext.getCurrentInstance();
FacesMessage msg = null;
boolean loggedIn = false;
if(username != null && username.equals("admin") && password != null && password.equals("admin")) {
loggedIn = true;
msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Welcome", username);
} else {
loggedIn = false;
msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Login Error", "Invalid credentials");
}
FacesContext.getCurrentInstance().addMessage(null, msg);
context.addCallbackParam("loggedIn", loggedIn);
if (loggedIn == true) {
System.out.println("entrou no if para chamar logged");
logged();
}
}
public String logged() {
System.out.println("LoginBean.logged()");
return "index.xhtml";
}
}
Chamando a index como pagina inicial:
Chamando a dialogLogin, logando e em seguida o resultado da chamada da index: