String action = req.getParameter("action");
try {
DAOFactory df = DAOFactory.getInstance();
NotesDAO nDao = df.getDAO(Note.class, NotesDAO.class);
if(action.equals("create")){
String name = req.getParameter("name");
if(name != null && !name.equals(""))
nDao.createNotesList(user.getUserId(), name);
}
else if(action.equals("delete")){
String keyString = req.getParameter("key");
Key notesListKey = KeyFactory.stringToKey(keyString);
NoteList nl = new NoteList();
nl.setKey(notesListKey);
nDao.deleteNotesList(nl);
}
resp.sendRedirect(NOTELISTS_SERVLET);
} catch (DAOException e) {
errorOccured(resp);