Advertisement
PyGuy91

TodoApplication.jsp

May 16th, 2013
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.01 KB | None | 0 0
  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
  2. <%@ page import="java.util.List" %>
  3. <%@ page import="com.google.appengine.api.users.User" %>
  4. <%@ page import="com.google.appengine.api.users.UserService" %>
  5. <%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
  6. <%@ page import="com.chrismcnulty.gaetutorial.Todo" %>
  7. <%@ page import="com.chrismcnulty.gaetutorial.Dao" %>
  8. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  9. <%@ page import="java.util.ArrayList" %>
  10.  
  11. <html>
  12. <head>
  13. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  14.     <title>Todos</title>
  15.     <link rel="Stylesheet" type= "text/css" href="css/main.css"/>
  16. </head>
  17.     <body>
  18.    
  19.         <%
  20.             Dao dao = Dao.INSTANCE;
  21.             UserService userService = UserServiceFactory.getUserService();
  22.             User user = userService.getCurrentUser();
  23.            
  24.             String url = userService.createLoginURL(request.getRequestURI());
  25.             String urlLinkText = "Login";
  26.             List<Todo> todos = new ArrayList<Todo>();
  27.            
  28.             if(user != null) {
  29.                
  30.                 url = userService.createLogoutURL(request.getRequestURI());
  31.                 urlLinkText = "Logout";
  32.                 todos = dao.getTodo(user.getUserId());
  33.             }
  34.         %>
  35.        
  36.         <div style="width: 100%">
  37.             <div class="line"></div>
  38.             <div class="topLine">
  39.                 <div style="float: left;"></div>
  40.                 <div style="float: left;" class="headLine">Todos</div>
  41.                 <div style="float: right"><a href="<%=url %>"><%=urlLinkText%></a> <%=(user == null ? "" : user.getNickname()) %></div>
  42.             </div>
  43.         </div>
  44.        
  45.         <div style="clear: both"></div>
  46.             You have a total number of <%= todos.size() %> Todos.
  47.            
  48.             <table>
  49.                 <tr>
  50.                     <th>Summary</th>
  51.                     <th>Description</th>
  52.                     <th>URL</th>
  53.                     <th>Done</th>
  54.                 </tr>
  55.                
  56.                 <% for (Todo todo : todos) { %>
  57.                     <tr>
  58.                         <td> <%=todo.getSummary() %> </td>
  59.                         <td> <%=todo.getDescription() %></td>
  60.                         <td> <%=todo.getURL() %></td>
  61.                         <td> <a class="done" href="/done?id=<%=todo.getID() %>">Done</a></td>
  62.                     </tr>
  63.                 <% } %>
  64.             </table>
  65.         <hr />
  66.        
  67.         <div class = "main">
  68.             <div class="headLine">New todo</div>
  69.            
  70.             <% if (user != null) { %>
  71.            
  72.                 <form action="/new" method="post" accept-charset="utf-8">
  73.                     <table>
  74.                         <tr>
  75.                             <td><label for="summary">Summary</label></td>
  76.                             <td><input type="text" name="summary" id="summary" size="65" /></td>
  77.                         </tr>
  78.                         <tr>
  79.                             <td valign="description"><label for="description">Description</label></td>
  80.                             <td><textarea rows="4" cols="50" name="description" id="description"></textarea></td>
  81.                         </tr>
  82.                         <tr>
  83.                             <td valign="top"><label for="url">URL</label></td>
  84.                             <td><input type="url" name="url" id="url" size="65" /></td>
  85.                         </tr>
  86.                         <tr>
  87.                             <td colspan="2" align="right"><input type="submit" value="Create" /></td>
  88.                         </tr>
  89.                     </table>
  90.                 </form>
  91.                
  92.             <% } else { %>
  93.            
  94.                 Please login with your google account
  95.                
  96.             <% } %>
  97.            
  98.         </div>
  99.     </body>
  100. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement