* @wml_only modify_birth.vm
*/
protected ActionForward doUpdateBirth(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UserForm user = (UserForm) form;
super.validateClientId(request, user);
ActionMessages msgs = new ActionMessages();
while (msgs.isEmpty()) {
UserBean loginUser = super.getLoginUser(request, response);
if(loginUser == null) {
msgs.add("user", new ActionMessage("error.user_not_login"));
break;
}
if(loginUser.getId() != user.getId()){
msgs.add("user", new ActionMessage("error.access_deny"));
break;
}
UserBean ubean = UserDAO.getUserByID(user.getId());
if (ubean == null || ubean.getStatus()!=UserBean.STATUS_NORMAL) {
msgs.add("id", new ActionMessage("error.user_not_available",
new Integer(user.getId())));
break;
}
if (!StringUtils.equals(ubean.getPassword(), user
.getPassword())){
msgs.add("password",
new ActionMessage("error.user_auth_failed"));
break;
}
boolean update = false;
if(StringUtils.isNotEmpty(user.getSbirth())){
try{
int birth = Integer.parseInt(user.getSbirth());
int year = birth / 10000;
int month = (birth % 10000) / 100;
int date = birth % 100;
long lbirth = DateUtils.getDateBegin(year,month,date).getTime().getTime();
ubean.setBirth(new java.sql.Date(lbirth));
System.out.println("================= new birth is " + ubean.getBirth());
update = true;
}catch(Exception e){}
}
if(update){
try {
DLOGUserManager.update(ubean);
//����session�е��û�����
UserLoginManager.updateLoginUser(request, ubean);
} catch (Exception e) {
msgs.add("result", new ActionMessage("error.database", e
.getMessage()));
}
}
break;
}
if (!msgs.isEmpty()) {
saveMessages(request, msgs);
return mapping.findForward("edituser");
}
StringBuffer ext = new StringBuffer();
ext.append("uid=");
ext.append(user.getId());
return makeForward(mapping.findForward("viewuser"), user.getSid(), ext.toString());
}