?? editaccountaction.java
字號:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.icome.struts.action;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import com.icome.bo.AccountBO;
import com.icome.entity.Account;
import com.icome.struts.form.EditAccountForm;
/**
* MyEclipse Struts
* Creation date: 12-17-2006
*
* XDoclet definition:
* @struts.action path="/editAccount" name="editAccountForm" input="/form/editAccount.jsp" scope="request" validate="true"
*/
public class EditAccountAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* @throws ParseException
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
EditAccountForm editAccountForm = (EditAccountForm) form;// TODO Auto-generated method stub
HttpSession session=request.getSession();
ActionMessages errors=new ActionMessages();
String uid=(String)session.getAttribute("uid");
AccountBO aBO=new AccountBO();
Account a=aBO.findById(uid);
String f=null;
String s="你要編輯的用戶不存在";
if(a==null)
{
f="failure";
errors.add("userNotExist",new ActionMessage(s));
return mapping.findForward(f);
}
a.setAbout(editAccountForm.getAbout());
a.setAddress(editAccountForm.getAddress());
String birthyear=(String)editAccountForm.getBirthyear() ;
String birthmonth=(String)editAccountForm.getBirthmonth();
String birthday=(String)editAccountForm.getBirthday();
String g=birthyear+"/"+birthmonth+"/"+birthday;
SimpleDateFormat df=new SimpleDateFormat("yyyy/MM/dd");
Date d=null;
try
{
//d=fm.parse(g);
d=df.parse(g);
}
catch(ParseException pe)
{
String peError="你的生日輸入有錯誤 "+pe.toString();
errors.add("birthdayError",new ActionMessage(peError));
}
a.setBirthday(d);
a.setCellphone(editAccountForm.getCellphone());
a.setDepartment(editAccountForm.getDepartment());
a.setEmail(editAccountForm.getEmail());
a.setMsn(editAccountForm.getMsn());
a.setQq(editAccountForm.getQq());
a.setRealname(editAccountForm.getRealname());
a.setTelephone(editAccountForm.getTelephone());
a.setUniversity(editAccountForm.getUniversity());
a.setZipcode(editAccountForm.getZipcode());
String sex=editAccountForm.getSex();
Integer i=null;
if(sex.equals("male"))
i=new Integer(0);
else
i=new Integer(1);
a.setSex(i);
boolean b=aBO.save(a);
if(b)
{
f="success";
}
else
{
f="failure";
String m="編輯用戶信息失敗!";
errors.add("editAccountFailure",new ActionMessage(m));
}
if(!errors.isEmpty())
{
saveErrors(request, errors);
}
return mapping.findForward(f);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -