Olá, fiz um menu utilizando o seguinte código:
Página
<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.prime.com.tr/ui">
<fieldset>
<h:form>
<p:menu>
<p:submenu label="Sair">
<p:menuitem action="#{loginBean.sair}" value="Logoff" ajax="false"/>
</p:submenu>
</p:menu>
</h:form>
</fieldset>
</html>
O managed bean é o seguinte:
@ManagedBean
@SessionScoped
public class LoginBean {
private HttpSession session;
private Usuario usuario = new Usuario();
private Pessoa pessoa = new Pessoa();
private String mensagem;
private List<String> menu = new ArrayList<String>();
public String entrar() {
String retorno = "login";
try {
Usuarios usuarios = new Usuarios(DataBaseConnection.getInstance().getConnection());
setUsuario((Usuario) usuarios.setRecord(getUsuario()));
if (getUsuario().getId() > -1) {
UsuariosDePessoa usuariosDePessoa = new UsuariosDePessoa(DataBaseConnection.getInstance().getConnection());
UsuarioDePessoa usuarioDePessoa = (UsuarioDePessoa) usuariosDePessoa.setRecord(new UsuarioDePessoa(null, getUsuario()));
setPessoa(usuarioDePessoa.getPessoa());
setSession((HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false));
getSession().setAttribute("autenticacao", getPessoa());
retorno = "home";
}else{
setMensagem("Nome de usuário ou senha incorretos!");
}
} catch (SQLException ex) {
Logger.getLogger(LoginBean.class.getName()).log(Level.SEVERE, null, ex);
}
return retorno;
}
public String sair() {
setSession((HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false));
getSession().removeAttribute("autenticacao");
FacesContext context = FacesContext.getCurrentInstance();
context.getExternalContext().getSessionMap().remove("loginBean");
return "login";
}
private void sistemaDeUsuario(Usuario usuario) {
try {
PerfisDeUsuario perfisDeUsuario = new PerfisDeUsuario(DataBaseConnection.getInstance().getConnection());
PerfilDeUsuario perfilDeUsuario = (PerfilDeUsuario) perfisDeUsuario.setRecord(new PerfilDeUsuario(usuario, null));
SistemasDePerfil sistemasDePerfil = new SistemasDePerfil(DataBaseConnection.getInstance().getConnection());
Iterator iterator = sistemasDePerfil.search(new SistemaDePerfil(perfilDeUsuario.getPerfil(), null)).values().iterator();
} catch (SQLException ex) {
Logger.getLogger(LoginBean.class.getName()).log(Level.SEVERE, null, ex);
}
}
/**
* @return the session
*/
public HttpSession getSession() {
return session;
}
/**
* @param session the session to set
*/
public void setSession(HttpSession session) {
this.session = session;
}
/**
* @return the usuario
*/
public Usuario getUsuario() {
return usuario;
}
/**
* @param usuario the usuario to set
*/
public void setUsuario(Usuario usuario) {
this.usuario = usuario;
}
/**
* @return the pessoa
*/
public Pessoa getPessoa() {
return pessoa;
}
/**
* @param pessoa the pessoa to set
*/
public void setPessoa(Pessoa pessoa) {
this.pessoa = pessoa;
}
/**
* @return the mensagem
*/
public String getMensagem() {
return mensagem;
}
/**
* @param mensagem the mensagem to set
*/
public void setMensagem(String mensagem) {
this.mensagem = mensagem;
}
/**
* @return the menu
*/
public List<String> getMenu() {
return menu;
}
/**
* @param menu the menu to set
*/
public void setMenu(List<String> menu) {
this.menu = menu;
}
}
Porém quando clico no menu:
[Ljava.lang.Object; cannot be cast to com.sun.faces.application.view.StateHolderSaver
O que será que está ocorrendo.
Estou utilizando JSF 2.0 e primefaces.
Se alguem puder me ajudar eu agradeço.