Rev 2009 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2009 | Rev 2018 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | <%@ page import="pt.estgp.es.exemplos.hibernate.HibernateUtils" %> |
1 | <%@ page import="pt.estgp.es.exemplos.hibernate.HibernateUtils" %> |
2 | <%@ page import="pt.estgp.es.exemplos.hibernate.Pagina" %> |
2 | <%@ page import="pt.estgp.es.exemplos.hibernate.Pagina" %> |
3 | <%@ page import="pt.estgp.es.exemplos.hibernate.Seccao" %><%-- |
3 | <%@ page import="pt.estgp.es.exemplos.hibernate.Seccao" %> |
- | 4 | <%@ page import="pt.estgp.es.exemplos.hibernate.web.SecurityFilter" %><%-- |
|
4 | Created by IntelliJ IDEA. |
5 | Created by IntelliJ IDEA. |
5 | User: jmachado |
6 | User: jmachado |
6 | Date: 29/10/2018 |
7 | Date: 29/10/2018 |
7 | Time: 15:03 |
8 | Time: 15:03 |
8 | To change this template use File | Settings | File Templates. |
9 | To change this template use File | Settings | File Templates. |
9 | --%> |
10 | --%> |
10 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> |
11 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> |
- | 12 | <jsp:useBean scope="request" id="UserSession" type="pt.estgp.es.exemplos.hibernate.UserSession"/> |
|
- | 13 | ||
11 | <html> |
14 | <html> |
12 | <head> |
15 | <head> |
13 | <title></title> |
16 | <title></title> |
14 | </head> |
17 | </head> |
15 | <body> |
18 | <body> |
16 | 19 | ||
- | 20 | Olá ${UserSession.user.nome} estamos a ver uma página. |
|
- | 21 | ||
17 | <% |
22 | <% |
- | 23 | ||
- | 24 | pt.estgp.es.exemplos.hibernate.UserSession sess = SecurityFilter.loadSessionProxy(request); |
|
- | 25 | String id = request.getParameter("id"); |
|
- | 26 | HibernateUtils.getCurrentSession().beginTransaction(); |
|
- | 27 | ||
- | 28 | Long idLong = id != null ? new Long(id) : (Long) request.getAttribute("id"); |
|
18 | 29 | ||
19 | String id = request.getParameter("id"); |
- | |
20 | HibernateUtils.getCurrentSession().beginTransaction(); |
- | |
21 | 30 | ||
22 | Long idLong = id != null ? new Long(id) : (Long) request.getAttribute("id"); |
- | |
23 | 31 | ||
- | 32 | Pagina p = (Pagina) HibernateUtils.getCurrentSession().load(Pagina.class,idLong); |
|
24 | 33 | ||
- | 34 | %> |
|
25 | 35 | ||
26 | Pagina p = (Pagina) HibernateUtils.getCurrentSession().load(Pagina.class,idLong); |
36 | <h1><%=p.getNome()%> </h1> |
27 | 37 | ||
28 | %> |
- | |
- | 38 | <form action="<%=request.getContextPath()%>/paginas" method="post"> |
|
29 | 39 | ||
30 | <h1><%=p.getNome()%> </h1> |
40 | <input type="hidden" name="idPagina" value="<%=idLong%>"/> |
31 | 41 | ||
- | 42 | Adicionar Seccao<br/> |
|
32 | <form action="<%=request.getContextPath()%>/paginas" method="post"> |
43 | <input type="text" name="titulo"> |
33 | 44 | ||
34 | <input type="hidden" name="idPagina" value="<%=idLong%>"/> |
- | |
35 | 45 | ||
36 | Adicionar Seccao<br/> |
- | |
37 | <input type="text" name="titulo"> |
46 | <button type="submit">Criar</button> |
38 | 47 | ||
- | 48 | </form> |
|
39 | 49 | ||
- | 50 | <% |
|
40 | <button type="submit">Criar</button> |
51 | for(Seccao s: p.getSeccoes()) |
- | 52 | { |
|
41 | 53 | ||
42 | </form> |
- | |
43 | 54 | ||
44 | <% |
- | |
45 | for(Seccao s: p.getSeccoes()) |
- | |
46 | { |
- | |
47 | %> |
55 | %> |
48 | <h2><%=s.getTitulo()%> |
56 | <h2><%=s.getTitulo()%> |
49 | <a href="<%=request.getContextPath()%>/paginasDelete?idSeccao=<%=s.getId()%>"> |
57 | <a href="<%=request.getContextPath()%>/paginasDelete?idSeccao=<%=s.getId()%>"> |
50 | APAGAR |
58 | APAGAR |
51 | </a> |
59 | </a> |
52 | 60 | ||
53 | </h2> |
61 | </h2> |
54 | <% |
62 | <% |
55 | } |
63 | } |
56 | 64 | ||
57 | HibernateUtils.getCurrentSession().getTransaction().rollback(); |
65 | HibernateUtils.getCurrentSession().getTransaction().rollback(); |
58 | %> |
66 | %> |
59 | 67 | ||
60 | </body> |
68 | </body> |
61 | </html> |
69 | </html> |