Subversion Repositories bacoAlunos

Rev

Rev 2009 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@ page import="pt.estgp.es.exemplos.hibernate.HibernateUtils" %>
<%@ page import="pt.estgp.es.exemplos.hibernate.Pagina" %>
<%@ page import="pt.estgp.es.exemplos.hibernate.Seccao" %>
<%@ page import="pt.estgp.es.exemplos.hibernate.web.SecurityFilter" %><%--
  Created by IntelliJ IDEA.
  User: jmachado
  Date: 29/10/2018
  Time: 15:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:useBean scope="request" id="UserSession" type="pt.estgp.es.exemplos.hibernate.UserSession"/>

<html>
<head>
    <title></title>
</head>
<body>

Olá ${UserSession.user.nome} estamos a ver uma página.

<%

    pt.estgp.es.exemplos.hibernate.UserSession sess = SecurityFilter.loadSessionProxy(request);
    String id = request.getParameter("id");
    HibernateUtils.getCurrentSession().beginTransaction();

    Long idLong = id != null ? new Long(id) : (Long) request.getAttribute("id");



    Pagina p = (Pagina) HibernateUtils.getCurrentSession().load(Pagina.class,idLong);

%>

<h1><%=p.getNome()%>      </h1>

<form action="<%=request.getContextPath()%>/paginas" method="post">

    <input type="hidden" name="idPagina" value="<%=idLong%>"/>

    Adicionar Seccao<br/>
    <input type="text" name="titulo">


    <button type="submit">Criar</button>

</form>

<%
    for(Seccao s: p.getSeccoes())
    {


%>
<h2><%=s.getTitulo()%>
    <a href="<%=request.getContextPath()%>/paginasDelete?idSeccao=<%=s.getId()%>">
        APAGAR
    </a>

</h2>
<%
    }

    HibernateUtils.getCurrentSession().getTransaction().rollback();
%>

</body>
</html>