NoteManage.java
资源名称:Myblog.rar [点击查看]
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:2k
源码类别:
Jsp/Servlet
开发平台:
Java
- package com.opensource.blog.web.action;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionForward;
- import org.apache.struts.action.ActionMapping;
- import org.apache.struts.action.ActionMessage;
- import org.apache.struts.action.ActionMessages;
- import com.laoer.comm.web.PageList;
- import com.laoer.comm.web.Pages;
- import com.opensource.blog.exception.BlogException;
- import com.opensource.blog.model.Note;
- import com.opensource.blog.service.NoteService;
- import com.opensource.blog.web.form.NoteManageForm;
- import com.opensource.blog.web.servlet.UserSession;
- public class NoteManage
- extends BaseAction {
- private NoteService noteService;
- public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- NoteManageForm form = (NoteManageForm) actionForm;
- ActionMessages errors = new ActionMessages();
- UserSession us = this.getUserSession(servletRequest);
- if (form.getAction().equals("list")) {
- Pages pages = new Pages(servletRequest.getLocale());
- pages.setPage(form.getPage());
- pages.setPerPageNum(us.getBlog().getPerartnum());
- pages.setStyle(1);
- pages.setFileName("noteManage.do?action=" + form.getAction());
- PageList pl = this.getNoteService().findNotesByBlogID(us.getBlog().getId().longValue(), pages);
- servletRequest.setAttribute("pl", pl);
- return actionMapping.findForward("notemanage");
- }
- if (form.getAction().equalsIgnoreCase("del")) {
- Note note = this.getNoteService().findNoteByID_BlogID(form.getNoteid(),
- us.getBlog().getId().longValue());
- if (note != null) {
- try {
- this.getNoteService().removeNote(note);
- return new ActionForward("/noteManage.do?action=list", true);
- }
- catch (BlogException ex) {
- errors.add("error.note.del.error", new ActionMessage("error.note.del.error"));
- saveErrors(servletRequest, errors);
- return actionMapping.findForward("error");
- }
- }
- }
- return actionMapping.findForward("error");
- }
- public NoteService getNoteService() {
- return noteService;
- }
- public void setNoteService(NoteService noteService) {
- this.noteService = noteService;
- }
- }