📄 page1form.java
字号:
/*******************************************************************************
* ***** BEGIN LICENSE BLOCK Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* 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 the OpenCustomer CRM.
*
* The Initial Developer of the Original Code is Thomas Bader (Bader & Jene
* Software-Ingenieurb黵o). Portions created by the Initial Developer are
* Copyright (C) 2005 the Initial Developer. All Rights Reserved.
*
* Contributor(s): Thomas Bader <thomas.bader@bader-jene.de>
*
* ***** END LICENSE BLOCK *****
*/
package org.opencustomer.application.web.module.crm.contact.edit;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.util.ImageButtonBean;
import org.opencustomer.web.util.FormUtility;
import org.opencustomer.web.util.MessageUtil;
import org.opencustomer.web.util.RequestUtility;
public final class Page1Form extends DefaultPageForm
{
private static final long serialVersionUID = 3257571706599061552L;
private static Logger log = Logger.getLogger(Page1Form.class);
private String subject;
private String content;
private String contactName;
private String contactType;
private String boundType;
private String contactDate;
private String contactTime;
private int personId;
private int companyId;
private int jumpPersonId;
private int deletePersonId;
private ImageButtonBean doAddPerson = new ImageButtonBean();
private ImageButtonBean doJumpCompany = new ImageButtonBean();
private ImageButtonBean doAddOwnPerson = new ImageButtonBean();
private ImageButtonBean doAddCompany = new ImageButtonBean();
public void validate(ActionMapping mapping, ActionMessages errors, HttpServletRequest request)
{
if (log.isDebugEnabled())
log.debug("called form");
setDoPage1(null);
subject = FormUtility.adjustParameter(subject, 255);
content = FormUtility.adjustParameter(content);
contactName = FormUtility.adjustParameter(contactName, 255);
contactType = FormUtility.adjustParameter(contactType);
boundType = FormUtility.adjustParameter(boundType);
contactDate = FormUtility.adjustParameter(contactDate);
contactTime = FormUtility.adjustParameter(contactTime);
jumpPersonId = RequestUtility.parseParamId(request, "doJumpPerson_");
deletePersonId = RequestUtility.parseParamId(request, "doDeletePerson_");
if (isTokenValid(request))
{
if (log.isDebugEnabled())
log.debug("token is not valid");
}
else if (this.getDoSave() != null || this.isAnyPage() || this.getDoAddPerson().isSelected() || this.getDoAddCompany().isSelected() || this.getDoJumpCompany().isSelected() || this.getJumpPersonId() > 0 || this.getDeletePersonId() > 0)
{
if (contactDate == null)
{
errors.add("contactDate", new ActionMessage("default.error.missingInput", MessageUtil.message(request, "entity.crm.contact.contactTimestamp.date")));
}
else
{
String format = MessageUtil.message(request, "format.input.date");
SimpleDateFormat sdf = new SimpleDateFormat(format);
try
{
Date date = sdf.parse(contactDate);
contactDate = sdf.format(date);
}
catch (ParseException e)
{
errors.add("contactDate", new ActionMessage("default.error.invalidFormat", MessageUtil.message(request, "entity.crm.contact.contactTimestamp.date"), format));
}
}
if (contactTime == null)
{
errors.add("contactTime", new ActionMessage("default.error.missingInput", MessageUtil.message(request, "entity.crm.contact.contactTimestamp.time")));
}
else
{
String format = MessageUtil.message(request, "format.input.time");
SimpleDateFormat sdf = new SimpleDateFormat(format);
try
{
Date date = sdf.parse(contactTime);
contactTime = sdf.format(date);
}
catch (ParseException e)
{
errors.add("contactTime", new ActionMessage("default.error.invalidFormat", MessageUtil.message(request, "entity.crm.contact.contactTimestamp.time"), format));
}
}
}
}
public void reset()
{
subject = null;
content = null;
contactName = null;
contactType = null;
boundType = null;
contactDate = null;
contactTime = null;
personId = 0;
companyId = 0;
}
public final String getBoundType()
{
return boundType;
}
public final void setBoundType(String boundType)
{
this.boundType = boundType;
}
public final int getCompanyId()
{
return companyId;
}
public final void setCompanyId(int companyId)
{
this.companyId = companyId;
}
public final String getContactDate()
{
return contactDate;
}
public final void setContactDate(String contactDate)
{
this.contactDate = contactDate;
}
public final String getContactName()
{
return contactName;
}
public final void setContactName(String contactName)
{
this.contactName = contactName;
}
public final String getContactTime()
{
return contactTime;
}
public final void setContactTime(String contactTime)
{
this.contactTime = contactTime;
}
public final String getContactType()
{
return contactType;
}
public final void setContactType(String contactType)
{
this.contactType = contactType;
}
public final String getContent()
{
return content;
}
public final void setContent(String content)
{
this.content = content;
}
public final int getPersonId()
{
return personId;
}
public final void setPersonId(int personId)
{
this.personId = personId;
}
public final String getSubject()
{
return subject;
}
public final void setSubject(String subject)
{
this.subject = subject;
}
public final ImageButtonBean getDoJumpCompany()
{
return doJumpCompany;
}
public final void setDoJumpCompany(ImageButtonBean doJumpCompany)
{
this.doJumpCompany = doJumpCompany;
}
/**
* @return Returns the doAddPerson.
*/
public final ImageButtonBean getDoAddPerson()
{
return doAddPerson;
}
/**
* @param doAddPerson The doAddPerson to set.
*/
public final void setDoAddPerson(ImageButtonBean doAddPerson)
{
this.doAddPerson = doAddPerson;
}
/**
* @return Returns the jumpPersonId.
*/
public final int getJumpPersonId()
{
return jumpPersonId;
}
/**
* @param jumpPersonId The jumpPersonId to set.
*/
public final void setJumpPersonId(int jumpPersonId)
{
this.jumpPersonId = jumpPersonId;
}
/**
* @return Returns the deletePersonId.
*/
public final int getDeletePersonId()
{
return deletePersonId;
}
/**
* @param deletePersonId The deletePersonId to set.
*/
public final void setDeletePersonId(int deletePersonId)
{
this.deletePersonId = deletePersonId;
}
/**
* @return Returns the doAddOwnPerson.
*/
public final ImageButtonBean getDoAddOwnPerson()
{
return doAddOwnPerson;
}
/**
* @param doAddOwnPerson The doAddOwnPerson to set.
*/
public final void setDoAddOwnPerson(ImageButtonBean doAddOwnPerson)
{
this.doAddOwnPerson = doAddOwnPerson;
}
/**
* @return Returns the doAddCompany.
*/
public final ImageButtonBean getDoAddCompany()
{
return doAddCompany;
}
/**
* @param doAddCompany The doAddCompany to set.
*/
public final void setDoAddCompany(ImageButtonBean doAddCompany)
{
this.doAddCompany = doAddCompany;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -