showcompanies2form.java

来自「开源项目CRM之OpenCustomer」· Java 代码 · 共 256 行

JAVA
256
字号
/*******************************************************************************
 * ***** 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.company;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

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.application.web.struts.ActionForm;
import org.opencustomer.web.util.FormUtility;
import org.opencustomer.web.util.MessageUtil;
import org.opencustomer.web.util.Sort;

public final class ShowCompanies2Form extends ActionForm
{
    private static final long serialVersionUID = 3689636878265563448L;

    private String companyName;

    private int companyStateId;

    private int companyTypeId;

    private int sectorId;

    private String lastContactDateStart;

    private String lastContactDateEnd;

    private ImageButtonBean doSearch = new ImageButtonBean();

    private ImageButtonBean doResetSearch = new ImageButtonBean();

    private String sort;

    private int page;

    public void validate(ActionMapping mapping, ActionMessages errors, HttpServletRequest request)
    {
        companyName = FormUtility.adjustParameter(companyName);
        lastContactDateStart = FormUtility.adjustParameter(lastContactDateStart);
        lastContactDateEnd = FormUtility.adjustParameter(lastContactDateEnd);
        sort = FormUtility.adjustParameter(sort);

        sort = Sort.parseRequest(request, sort);

        if (!isTokenValid(request) || doResetSearch.isSelected())
        {
            reset();
        }
        else
        {
            String format = MessageUtil.message(request, "format.input.date");
            SimpleDateFormat sdf = new SimpleDateFormat(format);

            if (lastContactDateStart != null)
            {
                try
                {
                    Date date = sdf.parse(lastContactDateStart);
                    lastContactDateStart = sdf.format(date);
                }
                catch (ParseException e)
                {
                    errors.add("lastContactDate", new ActionMessage("default.error.invalidFormat", MessageUtil.message(request, "domain.crm.company.showCompanies2.lastContactDateStart"), format));
                }
            }
            if (lastContactDateEnd != null)
            {
                try
                {
                    Date date = sdf.parse(lastContactDateEnd);
                    lastContactDateEnd = sdf.format(date);
                }
                catch (ParseException e)
                {
                    errors.add("lastContactDate", new ActionMessage("default.error.invalidFormat", MessageUtil.message(request, "domain.crm.company.showCompanies2.lastContactDateEnd"), format));
                }
            }
        }
    }

    public void reset()
    {
        companyName = null;
        companyStateId = 0;
        companyTypeId = 0;
        sectorId = 0;
        lastContactDateStart = null;
        lastContactDateEnd = null;
    }

    public final String getCompanyName()
    {
        return companyName;
    }

    public final void setCompanyName(String companyName)
    {
        this.companyName = companyName;
    }

    public final ImageButtonBean getDoSearch()
    {
        return doSearch;
    }

    public final void setDoSearch(ImageButtonBean doSearch)
    {
        this.doSearch = doSearch;
    }

    public final ImageButtonBean getDoResetSearch()
    {
        return doResetSearch;
    }

    public final void setDoResetSearch(ImageButtonBean doResetSearch)
    {
        this.doResetSearch = doResetSearch;
    }

    public final int getPage()
    {
        return page;
    }

    public final void setPage(int page)
    {
        this.page = page;
    }

    /**
     * @return Returns the sort.
     */
    public final String getSort()
    {
        return sort;
    }

    /**
     * @param sort The sort to set.
     */
    public final void setSort(String sort)
    {
        this.sort = sort;
    }

    /**
     * @return Returns the companyStateId.
     */
    public final int getCompanyStateId()
    {
        return companyStateId;
    }

    /**
     * @param companyStateId The companyStateId to set.
     */
    public final void setCompanyStateId(int companyStateId)
    {
        this.companyStateId = companyStateId;
    }

    /**
     * @return Returns the companyTypeId.
     */
    public final int getCompanyTypeId()
    {
        return companyTypeId;
    }

    /**
     * @param companyTypeId The companyTypeId to set.
     */
    public final void setCompanyTypeId(int companyTypeId)
    {
        this.companyTypeId = companyTypeId;
    }

    /**
     * @return Returns the sectorId.
     */
    public final int getSectorId()
    {
        return sectorId;
    }

    /**
     * @param sectorId The sectorId to set.
     */
    public final void setSectorId(int sectorId)
    {
        this.sectorId = sectorId;
    }

    /**
     * @return Returns the lastContactDateEnd.
     */
    public final String getLastContactDateEnd()
    {
        return lastContactDateEnd;
    }

    /**
     * @param lastContactDateEnd The lastContactDateEnd to set.
     */
    public final void setLastContactDateEnd(String lastContactDateEnd)
    {
        this.lastContactDateEnd = lastContactDateEnd;
    }

    /**
     * @return Returns the lastContactDateStart.
     */
    public final String getLastContactDateStart()
    {
        return lastContactDateStart;
    }

    /**
     * @param lastContactDateStart The lastContactDateStart to set.
     */
    public final void setLastContactDateStart(String lastContactDateStart)
    {
        this.lastContactDateStart = lastContactDateStart;
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?