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

📄 inithyaction.java

📁 struts+hibernate3的源程序
💻 JAVA
字号:
package org.helpsoft.actions;

import javax.servlet.*;
import javax.servlet.http.*;
import java.text.SimpleDateFormat;
import org.helpsoft.servicelocator.*;
import org.helpsoft.session.AssociatorManageService;
import org.apache.struts.action.*;

import com.helpsoft.util.log.*;
import com.helpsoft.util.*;
import com.helpsoft.util.genelv.struts.GenericAction;
import org.helpsoft.session.*;
import org.helpsoft.entity.hy.*;
import com.helpsoft.Constants;
import org.helpsoft.forms.*;


/**
 * Struts 'Init' Action; prepares any information needed prior to displaying the 'hyForm'.
 *
 * @author  cao guangxin - www.relationinfo.com
 * @struts.action path="/initHy"
 *                type="org.helpsoft.actions.InitHyAction"
 *                name="hyForm"
 *                scope="session"
 *                validate="false"
 * @struts.action-forward name="success" path="/hy.jsp"
 */
public class InitHyAction extends ServiceAction {
   private Logger log = LogService.getLogger(this.getClass());

   /**
    * 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 {
      log.info("start doPerform");
      HyForm form = (HyForm) actionForm;
      HttpSession session  = request.getSession();
      String hykh = request.getParameter("hykh");

      if (hykh != null && hykh.equalsIgnoreCase("null")) {
         hykh = null;
      }

      if (form == null) {
         form = new HyForm();

         if ("request".equals(mapping.getScope())) {
            request.setAttribute(mapping.getAttribute(), form);
         }
         else {
            session.setAttribute(mapping.getAttribute(), form);
         }
      }

      if (hykh != null &&  true) { // hack to allow automatic generation of sources with JAG
         try {
            form.setMode("change");
            HyIf hyData = getAssociatorManageService().getHy(new java.lang.String(hykh));
            PropertyUtilsExt.copyProperties(form, hyData);

            HyklxForm hyklxHykmmForm = new HyklxForm();
            org.helpsoft.entity.hyklx.HyklxIf hyklxHykmm = hyData.getHykmmHyklx();
            if (hyklxHykmm != null) {
               PropertyUtilsExt.copyProperties(hyklxHykmmForm, hyklxHykmm);
               form.setHykmmHyklx(hyklxHykmmForm);
            }
         }
         catch (Throwable t) {
            servlet.log("InitHyAction :", t);
            throw new ServletException("InitHyAction :", t);
         }
      }
      else {
         form.setMode("new");
         PropertyUtilsExt.copyProperties(form, new HyData());
      }
      return mapping.findForward("success");
   }
}

⌨️ 快捷键说明

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