Package de.paulwein.notes

Source Code of de.paulwein.notes.NoteListServlet

package de.paulwein.notes;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

import de.paulwein.notes.dao.DAOException;
import de.paulwein.notes.dao.DAOFactory;
import de.paulwein.notes.dao.NotesDAO;
import de.paulwein.notes.pojo.Note;
import de.paulwein.notes.pojo.NoteList;

/**
* NotesListServlet
* loads all notes of the corresponding list
* corresponding to noteslist.jsp
* @author Paul
*
*/
@SuppressWarnings("serial")
public class NoteListServlet extends NotesAppServlet {
 
  // load notes and show them in jsp page
  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    super.doGet(req, resp);
   
    String keyString = req.getParameter("key");
    Key listKey = KeyFactory.stringToKey(keyString);
   
    try {
      DAOFactory df = DAOFactory.getInstance();
      NotesDAO nDao = df.getDAO(Note.class, NotesDAO.class);
      NoteList notesList = nDao.loadNotesList(listKey);
      req.setAttribute("key", keyString);
      req.setAttribute("list", notesList.getNotes());
      RequestDispatcher requestDispatcher = req.getRequestDispatcher(NOTELIST_SERVLET + ".jsp");
      requestDispatcher.forward(req, resp);
    } catch (DAOException e) {
      errorOccured(resp);
    } catch (ServletException e) {
      errorOccured(resp);
    }
   
  }
}
TOP

Related Classes of de.paulwein.notes.NoteListServlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.