/********************************************************************************* * The contents of this file are subject to the Common Public Attribution * License Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.openemm.org/cpal1.html. The License is based on the Mozilla * Public License Version 1.1 but Sections 14 and 15 have been added to cover * use of software over a computer network and provide for limited attribution * for the Original Developer. In addition, Exhibit A has been modified to be * consistent with Exhibit B. * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License. * * The Original Code is OpenEMM. * The Original Developer is the Initial Developer. * The Initial Developer of the Original Code is AGNITAS AG. All portions of * the code written by AGNITAS AG are Copyright (c) 2007 AGNITAS AG. All Rights * Reserved. * * Contributor(s): AGNITAS AG. ********************************************************************************/ package org.agnitas.web; import org.agnitas.web.forms.StrutsFormBase; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; import org.apache.struts.util.MessageResources; import javax.servlet.http.HttpServletRequest; import java.util.Locale; /** * * @author mhe */ public class MailinglistForm extends StrutsFormBase { private static final long serialVersionUID = -6130892396789216060L; /** * Holds value of property mailinglistID. */ private int mailinglistID; /** * Holds value of property targetID. */ private Integer targetID; /** * Holds value of property shortname. */ private String shortname; /** * Holds value of property description. */ private String description; /** * Holds value of property action. */ private int action; protected int previousAction; /** * Creates a new instance of MailinglistForm */ protected boolean activeOnly; protected boolean notAdminsAndTest; public MailinglistForm() { } /** * 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) { this.mailinglistID = 0; targetID = null; Locale aLoc=(Locale)request.getSession().getAttribute(org.apache.struts.Globals.LOCALE_KEY); MessageResources text=(MessageResources)this.getServlet().getServletContext().getAttribute(org.apache.struts.Globals.MESSAGES_KEY); this.shortname = text.getMessage(aLoc, "default.shortname"); this.description = text.getMessage(aLoc, "default.description"); } /** * Validate the properties that have been set from this HTTP request, * and return an <code>ActionErrors</code> object that encapsulates any * validation errors that have been found. If no errors are found, return * <code>null</code> or an <code>ActionErrors</code> object with no * recorded error messages. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing * @return errors */ public ActionErrors formSpecificValidate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if(action==MailinglistAction.ACTION_SAVE || action==MailinglistAction.ACTION_NEW) { if(this.shortname.length()<3) { errors.add("shortname", new ActionMessage("error.nameToShort")); } } return errors; } /** * Getter for property mailinglistID. * * @return Value of property mailinglistID. */ public int getMailinglistID() { return this.mailinglistID; } /** * Setter for property mailinglistID. * * @param mailinglistID New value of property mailinglistID. */ public void setMailinglistID(int mailinglistID) { this.mailinglistID = mailinglistID; } /** * Getter for property shortname. * * @return Value of property shortname. */ public String getShortname() { return this.shortname; } /** * Setter for property shortname. * * @param shortname New value of property shortname. */ public void setShortname(String shortname) { this.shortname = shortname; } /** * Getter for property description. * * @return Value of property description. */ public String getDescription() { return this.description; } /** * Setter for property description. * * @param description New value of property description. */ public void setDescription(String description) { this.description = description; } /** * Getter for property action. * * @return Value of property action. */ public int getAction() { return this.action; } /** * Setter for property action. * * @param action New value of property action. */ public void setAction(int action) { this.action = action; } public Integer getTargetID() { return targetID; } public void setTargetID(Integer targetID) { this.targetID = targetID; } public int getPreviousAction() { return previousAction; } public void setPreviousAction(int previousAction) { this.previousAction = previousAction; } public boolean isActiveOnly() { return activeOnly; } public void setActiveOnly(boolean activeOnly) { this.activeOnly = activeOnly; } public boolean isNotAdminsAndTest() { return notAdminsAndTest; } public void setNotAdminsAndTest(boolean notAdminsAndTest) { this.notAdminsAndTest = notAdminsAndTest; } }