Quantcast
Channel: Últimos conteúdos
Viewing all articles
Browse latest Browse all 14190

Block/None em div dentro de jsp!

$
0
0
Pessoal, tenho um jsp de cabeçalho que testa se o usuário esta loado ou não!
 
Estou adicionando ele às páginas antes da tag <html>.
 
Porem, tenho um menu que, dependendo do tipo de usuário (Administrador) que estiver logado, se ele for Super (s), ele terá um menu, se for Normal (n), seu menu será outro, então fiz 2 div's uma para colocar cada menu e chamei uma de super e a outra de normal.
 
Fiz o teste para saber o tipo do usuário mas não estou conseguindo bloquear a outra div.
 
<%@ page import="model.Admin" %>
<%
HttpSession sessao = request.getSession();
 
if (sessao.getAttribute("admin")!=null)
{  
 Admin admin = (Admin) sessao.getAttribute("admin");
 String tipo = admin.getTipo();
 out.println("Olá "+admin.getNome());
 sessao.setAttribute("tipoAdmin", tipo);
 
 if (sessao.getAttribute("nomeAdmin") != null)
 {  
 sessao.removeAttribute("nomeAdmin"); 
 }
 
 
 
 if (tipo == "s")
 {
 out.print("<script>$('#super').style.display='block';</script>");
 out.print("<script>$('#comum').style.display='none';</script>");
 }
 if (tipo == "c")
 {
 out.print("<script>$('#super').style.display='none';</script>");
 out.print("<script>$('#comum').style.display='block';</script>");
 }
}
else
{
response.sendRedirect("index.jsp");
}
%>
Página jsp:
<%@ include file="../../../_global/testaAdmin.jsp"%>
<%@ include file="../../../_global/sessoes.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>    
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="../_global/_css/estiloSite.css" />
<title><%=tituloSiteAdmin %></title>
</head>
<body>
 
 <div id="topo"> <jsp:include page="../_global/topoAdmin.jsp" /> </div>
 <div id="meio"> <jsp:include page="cadastraAdminConteudo.jsp" /> </div>
 <div id="mapa"> <jsp:include page="../_global/mapaAdmin.jsp" /> </div>
 <div id="creditos"> <jsp:include page="../_global/creditosAdmin.jsp" /> </div>
 
 </body>
</html>
topo.jsp (que contem os menus)
<div id="topoMeio">
 <div id="super">
  <table  style="text-align:center; " border=1>
    <tr><th colspan="5" style="text-align:center; height: 30px;">MENU</th></tr>
    <tr>
        <td style="text-align:center; width:150px; heght:30px;"><a href="listarSalas.jsp">Listar Salas</a></td>
        <td style="text-align:center; width:150px; heght:30px;"><a href="listarProfessores.jsp">Listar Professores</a></td>
        <td style="text-align:center; width:150px; heght:30px;"><a href="listarUsuarios.jsp">Listar Usuários</a></td>
        <td style="text-align:center; width:150px; heght:30px;"><a href="listarAdmin.jsp">Listar Administradores</a></td>
        <td style="text-align:center; width:150px; heght:30px;"><a href="../AdminServlet?acao=sair">Sair</a></td>
     </tr>
     <tr>
        <td style="text-align:center; width:150px; heght:30px;"><a href="cadastraSala.jsp">Adicionar Sala</a></td>
        <td style="text-align:center; width:150px; heght:30px;"><a href="cadastraProfessor.jsp">Adicionar Professor</a></td>
        <td style="text-align:center; width:150px; heght:30px;"><a href="cadastraUsuario.jsp">Adicionar Usuário</a></td>
        <td style="text-align:center; width:150px; heght:30px;"><a href="cadastraAdmin.jsp">Cadastrar Admin</a></td>
        <td style="text-align:center; width:150px; heght:30px;"></td>
     </tr>  
    </table>
   </div>
 <div id="comum">
  <table  style="text-align:center; " border=1>
    <tr><th colspan="4" style="text-align:center; height: 30px;">MENU</th></tr>
    <tr>
        <td style="text-align:center; width:150px; heght:30px;"><a href="listarSalas.jsp">Listar Salas</a></td>
        <td style="text-align:center; width:150px; heght:30px;"><a href="listarProfessores.jsp">Listar Professores</a></td>
        <td style="text-align:center; width:150px; heght:30px;"><a href="listarUsuarios.jsp">Listar Usuários</a></td>
        <td style="text-align:center; width:150px; heght:30px;"><a href="listarAdmin.jsp">Alterare sua senha</a></td>
     </tr>
     <tr>
        <td style="text-align:center; width:150px; heght:30px;"><a href="cadastraSala.jsp">Adicionar Sala</a></td>
        <td style="text-align:center; width:150px; heght:30px;"><a href="cadastraProfessor.jsp">Adicionar Professor</a></td>
        <td style="text-align:center; width:150px; heght:30px;"><a href="senhaAdministrador.jsp?id=1">Adicionar Usuário</a></td>
        <td style="text-align:center; width:150px; heght:30px;"><a href="../AdminServlet?acao=sair">Sair</a></td>
     </tr>  
    </table>
   </div>
</div>
O que fazer nesse caso?
 

Viewing all articles
Browse latest Browse all 14190

Trending Articles