📄 addtpcaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package mokoda.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import mokoda.entity.Client;
import mokoda.entity.Forum;
import mokoda.entity.ForumDAO;
import mokoda.entity.Message;
import mokoda.entity.MessageDAO;
import mokoda.entity.Msg2client;
import mokoda.entity.Msg2clientDAO;
import mokoda.entity.Msg2clientId;
import mokoda.entity.Tpc2frm;
import mokoda.entity.Tpc2frmDAO;
import mokoda.entity.Tpc2frmId;
import mokoda.form.AddtpcForm;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
/**
* MyEclipse Struts
* Creation date: 12-20-2006
*
* XDoclet definition:
* @struts.action path="/addtpc" name="addtpcForm" input="/msg/addtpc.jsp" scope="request" validate="true"
* @struts.action-forward name="success" path="/success.jsp"
*/
public class AddtpcAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
AddtpcForm tpcform = (AddtpcForm) form;
Message msg = new Message();
MessageDAO dao = new MessageDAO();
msg.setContent(tpcform.getContent());
msg.setIstpc("true");
msg.setTitle(tpcform.getTitle());
msg.setTpcid(0);
dao.save(msg);
msg.setTpcid(msg.getId());
dao.save(msg);
Msg2client mc = new Msg2client();
Msg2clientDAO mcdao = new Msg2clientDAO();
Msg2clientId mcid = new Msg2clientId();
mcid.setClientid(tpcform.getClientid());
mcid.setMsgid(msg.getId());
mc.setId(mcid);
mcdao.save(mc);
mcdao.getSession().flush();
Tpc2frm tf = new Tpc2frm();
Tpc2frmDAO tfdao = new Tpc2frmDAO();
Tpc2frmId tfid = new Tpc2frmId();
tfid.setTpcid(msg.getId());
tfid.setFrmid(tpcform.getForumid());
tf.setId(tfid);
tfdao.save(tf);
tfdao.getSession().flush();
dao.getSession().flush();
//Integer i = tpcform.getForumid();
//Forum f = new ForumDAO().findById(tpcform.getForumid());
request.setAttribute("forum", new ForumDAO().findById(tpcform.getForumid()));
request.setAttribute("topics", ForumDAO.getAllTpcs(tpcform.getForumid()));
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -