⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 initspsearchaction.java

📁 STRUTS数据库项目开发宝典
💻 JAVA
字号:
package org.helpsoft.actions;

import java.util.Collection;
import java.util.Iterator;
import java.util.ArrayList;

import javax.servlet.http.*;
import org.helpsoft.servicelocator.*;
import org.helpsoft.session.AssociatorManageService;
import org.apache.struts.action.*;
import org.apache.commons.beanutils.BeanUtils;

import com.helpsoft.util.log.*;
import org.helpsoft.session.*;
import org.helpsoft.forms.SpSearchForm;
import org.helpsoft.entity.sp.*;

/**
 * The initialise Action for the sp search screen.
 *
 * @author  cao guangxin - www.relationinfo.com
 * @struts.action path="/initSpSearch"
 *                type="org.helpsoft.actions.InitSpSearchAction"
 *                name="spSearchForm"
 *                scope="request"
 *                validate="false"
 * @struts.action-forward name="success" path="/spList.jsp"
 */
public class InitSpSearchAction extends ServiceAction {

   private static Logger log = LogService.getLogger(InitSpSearchAction.class);

   /**
    * Performs an action.
    *
    * @param mapping The ActionMapping used to select this instance
    * @param actionForm The optional ActionForm bean for this request (if any)
    * @param request The optional ActionForm bean for this request (if any)
    * @param response The HTTP response we are creating
    * @return describes where and how control should be forwarded, or <code>null</code> if the response has already
    *         been completed
    * @throws Exception in case of an error
    */
   public ActionForward doPerform(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
                                  HttpServletResponse response) throws Exception {
      Collection spList =
            getAssociatorManageService().getSpList();
      // We decorate the list with data objects that contain presentation specific methods
      ArrayList result = new ArrayList();
      if (spList != null) {
      Iterator iterator = spList.iterator();
         while (iterator.hasNext()) {
            SpIf object =  (SpIf) iterator.next();
            SpData data = new SpData();
            try {
               BeanUtils.copyProperties(data, object);
            } catch (Exception e) {
               // As fallback, we use the data constructor.
               log.warn("Error while copying properties using BeanUtils. Use fallback constructor...", e);
               data = new SpData(object);
            }
            result.add(data);
         }
      }
      ((SpSearchForm) actionForm).setSpList(result);
      return mapping.findForward("success");
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -