SortAction.java
资源名称:Myblog.rar [点击查看]
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:2k
源码类别:
Jsp/Servlet
开发平台:
Java
- package com.opensource.blog.web.action;
- import java.util.*;
- import javax.servlet.http.*;
- import org.apache.struts.action.*;
- import org.apache.struts.util.*;
- import com.opensource.blog.model.*;
- import com.opensource.blog.service.*;
- import com.opensource.blog.web.form.*;
- import com.opensource.blog.web.servlet.*;
- public class SortAction
- extends BaseAction {
- private SortService sortService;
- public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- //ActionMessages errors = new ActionMessages();
- SortForm form = (SortForm) actionForm;
- UserSession us = this.getUserSession(servletRequest);
- if (form.getAction().equalsIgnoreCase("show")) {
- MessageResources messages = getResources(servletRequest);
- Locale locale = getLocale(servletRequest);
- List sortSelList = new ArrayList();
- List sortlist = this.getSortService().findSortsByBlogID(us.getBlog().getId().longValue());
- sortSelList.add(new LabelValueBean(messages.getMessage(locale, "blog.select"), "0"));
- for (int i = 0; i < sortlist.size(); i++) {
- Sort sort = (Sort) sortlist.get(i);
- sortSelList.add(new LabelValueBean(sort.getSortname(), String.valueOf(sort.getId())));
- }
- if (form.getSortid() != 0) {
- Sort sort = this.getSortService().findSortByID_BlogID(form.getSortid(),
- us.getBlog().getId().longValue());
- if (sort != null) {
- form.setUpsortname(sort.getSortname());
- }
- }
- servletRequest.setAttribute("sortSelList", sortSelList);
- servletRequest.setAttribute("sortOptForm", form);
- return actionMapping.findForward("sort");
- }
- return actionMapping.findForward("error");
- }
- public SortService getSortService() {
- return sortService;
- }
- public void setSortService(SortService sortService) {
- this.sortService = sortService;
- }
- }