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

📄 inithysearchaction.java

📁 struts+hibernate3的源程序
💻 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.HySearchForm;
import org.helpsoft.entity.hy.*;

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

   private static Logger log = LogService.getLogger(InitHySearchAction.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 hyList =
            getAssociatorManageService().getHyList();
      // We decorate the list with data objects that contain presentation specific methods
      ArrayList result = new ArrayList();
      if (hyList != null) {
      Iterator iterator = hyList.iterator();
         while (iterator.hasNext()) {
            HyIf object =  (HyIf) iterator.next();
            HyData data = new HyData();
            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 HyData(object);
            }
            result.add(data);
         }
      }
      ((HySearchForm) actionForm).setHyList(result);
      return mapping.findForward("success");
   }
}

⌨️ 快捷键说明

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