📄 userform.java
字号:
/* * CyberTester - J2EE Web application for creating, delivering and managing tests/exams/surveys. * Copyright (C) 2004 CyberDemia Research and Services Pty Ltd * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, write to the * Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * See the COPYING file located in the top-level-directory of * the archive of this program for complete text of license. */package com.cyberdemia.cybertester.admin.user;import java.util.List;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.*;import com.cyberdemia.cybertester.admin.*;import com.cyberdemia.cybertester.CyberTesterUtils;/** * * UserForm is a Struts ActionForm to send, receive and validate values from the * user editor form. * * @version $Revision: 1.5 $ at $Date: 2004/05/27 13:49:52 $ by $Author: alexycyap $ * @author Alexander Yap */public final class UserForm extends ActionForm{ public Integer getId() { return m_id; } public void setId(Integer id) { m_id = id; } public String getEmail() { return m_email; } public void setEmail(String email) { m_email = email.trim(); } public String getPassword() { return m_password; } public void setPassword(String password) { m_password = password.trim(); } public String getPassword2() { return m_password2; } public void setPassword2(String password) { m_password2 = password.trim(); } public String getTitle() { return m_title; } public void setTitle(String title) { m_title = title; } public String getFirstName() { return m_firstName; } public void setFirstName(String name) { m_firstName = name.trim(); } public String getLastName() { return m_lastName; } public void setLastName(String name) { m_lastName = name.trim(); } public String getMode() { return m_mode; } public void setMode(String mode) { m_mode = mode; } public String getRoleGroup() { return m_roleGroup; } public void setRoleGroup(String roleGroup) { m_roleGroup = roleGroup; } public List getGroups() { return m_groupList; } public void setGroups(List groupList) { m_groupList = groupList; } public List getAvailableGroups() { return m_availableGroupList; } public void setAvailableGroups(List groupList) { m_availableGroupList = groupList; } public boolean isNew() { return AdminConstants.EDITOR_NEW_MODE.equalsIgnoreCase(m_mode); } /** * Reset all properties to their default values. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ public void reset(ActionMapping mapping, HttpServletRequest request) { m_id = null; m_email = null; m_password = null; m_title = null; m_firstName=null; m_lastName=null; m_roleGroup = null; m_groupList = null; m_availableGroupList = null; m_mode = AdminConstants.EDITOR_NEW_MODE; } public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if ((m_id==null)&&(!AdminConstants.EDITOR_NEW_MODE.equals(m_mode))) errors.add("id", new ActionError("error.user.id.missing")); if (CyberTesterUtils.validateRequiredFormEnteredParam("Email", m_email, errors)) { if ( !m_email.matches("^[a-zA-Z0-9][a-zA-Z0-9._-]*@[a-zA-Z0-9._-]*[a-zA-Z]$") ) { errors.add("emailInvalid", new ActionError("error.form.invalidParam","Email",m_email)); } } CyberTesterUtils.validateRequiredFormEnteredParam("First name", m_firstName, errors); CyberTesterUtils.validateRequiredFormEnteredParam("Last name", m_lastName, errors); if ( AdminConstants.EDITOR_NEW_MODE.equals(m_mode)) { CyberTesterUtils.validateRequiredFormEnteredParam("Password", m_password, errors); } if ( (m_password.length()>0) && (!m_password.equals(m_password2))) { errors.add("mismatchPassword", new ActionError("error.password.mismatch")); } return errors; } private Integer m_id = null; private String m_email = null; private String m_password = ""; private String m_password2 = ""; private String m_title = null; private String m_firstName=null; private String m_lastName=null; private String m_roleGroup = null; private String m_mode=AdminConstants.EDITOR_NEW_MODE; private List m_groupList = null; private List m_availableGroupList = null; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -