?? htfindbyprimarykeyaction.java
字號:
package org.helpsoft.contract.struts.actions;
import org.apache.struts.*;
import org.apache.struts.action.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.*;
import java.math.*;
import org.helpsoft.contract.dao.*;
import org.helpsoft.contract.dto.*;
import org.helpsoft.contract.factory.*;
import org.helpsoft.contract.struts.forms.*;
public class HtFindByPrimaryKeyAction extends Action
{
/**
* method'execute'
*
* @param mapping
* @param form
* @param request
* @param response
* @throws Exception
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
{
try {
// parse parameters
java.lang.String _htbm = request.getParameter("htbm");
// create the DAO class
HtDao dao = HtDaoFactory.create();
// execute the finder
Ht dto = dao.findByPrimaryKey(_htbm);
// check that we have found a row
if (dto == null) {
throw new RuntimeException( "Finder did not return any data" );
}
String crudMethod = request.getParameter("crudMethod");
if (crudMethod == null) {
crudMethod = "view";
}
// populate a struts form
HtForm htForm = new HtForm();
htForm.setCrudMethod( request.getParameter("crudMethod") );
htForm.setHtbm(dto.getHtbm());
htForm.setJfdlrbm(dto.getJfdlrbm());
htForm.setJfbm(dto.getJfbm());
htForm.setQsdd(dto.getQsdd());
htForm.setYf(dto.getYf());
htForm.setYfdlr(dto.getYfdlr());
htForm.setJfqzrq(dto.getJfqzrq() == null ? null : DateFormat.getDateTimeInstance().format( dto.getJfqzrq()));
htForm.setYfqzrq(dto.getYfqzrq() == null ? null : DateFormat.getDateTimeInstance().format( dto.getYfqzrq()));
htForm.setXmmc(dto.getXmmc());
htForm.setHtnr(dto.getHtnr());
// store the results
request.getSession().setAttribute( "Ht", htForm );
return mapping.findForward( crudMethod );
}
catch (Exception e) {
ActionErrors _errors = new ActionErrors();
_errors.add( ActionErrors.GLOBAL_ERROR, new ActionError("internal.error", e.getClass().getName() + ": " + e.getMessage() ) );
saveErrors( request, _errors );
return mapping.findForward( "failure" );
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -