⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shoeformbean.java

📁 A Java web application, based on Struts and Hibernate, that serves as an online running log. Users m
💻 JAVA
字号:
/* @LICENSE_COPYRIGHT@ */package net.sf.irunninglog.servlet.formbean;import javax.servlet.http.HttpServletRequest;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.apache.struts.action.ActionMapping;import net.sf.irunninglog.canonical.Shoe;import net.sf.irunninglog.servlet.UserContainer;import net.sf.irunninglog.util.ConstantValues;import net.sf.irunninglog.util.DTO;import net.sf.irunninglog.util.Utilities;/** * Form bean representation of the <em>Shoe</em> business object.  Used to * provide an implementation of the <em>Shoe</em> object within the * application's view tier. * * @author <a href="mailto:allan_e_lewis@yahoo.com">Allan Lewis</a> * @version $Revision: 1.1.1.1 $ $Date: 2005/06/23 01:49:02 $ * @since iRunningLog 1.0 */public class ShoeFormBean extends ReferenceDataFormBean {    /** <code>Log</code> instance for this class. */    private static final Log LOG = LogFactory.getLog(ShoeFormBean.class);    /** The bean's <em>start date</em> field. */    private String mStartDate;    /** The bean's <em>start mileage</em> field. */    private String mStartMileage;    /** The bean's <em>mileage</em> field. */    private String mMileage;    /** The bean's <em>total mileage</em> field. */    private String mTotalMileage;    /** The bean's <em>retired</em> field. */    private String mRetired;    /**     * Create a new form bean.     */    public ShoeFormBean() {        super();    }    /**     * Get the value of the bean's <em>start date</em> field.     *     * @return The current value of the <em>start date</em> field     */    public String getStartDate() {        return mStartDate;    }    /**     * Get the value of the bean's <em>start date</em> field, or a blank string     * if the <em>start date</em> is <code>null</code>.     *     * @return The current value of the <em>start date</em> field, or a blank     *         value if the <em>start date</em> is <code>null</code>     */    public String getStartDateOrBlank() {        return getValueOrBlank(getStartDate());    }    /**     * Set the value of the bean's <em>start date</em> field.     *     * @param value The value to be set onto the <em>start date</em> field     */    public void setStartDate(String value) {        mStartDate = value;    }    /**     * Get the value of the bean's <em>start mileage</em> field.     *     * @return The current value of the <em>start mileage</em> field     */    public String getStartMileage() {        return mStartMileage;    }    /**     * Set the value of the bean's <em>start mileage</em> field.     *     * @param value The value to be set onto the <em>start mileage</em> field     */    public void setStartMileage(String value) {        mStartMileage = value;    }    /**     * Get the value of the bean's <em>mileage</em> field.     *     * @return The current value of the <em>mileage</em> field     */    public String getMileage() {        return mMileage;    }    /**     * Set the value of the bean's <em>mileage</em> field.     *     * @param value The value to be set onto the <em>mileage</em> field     */    public void setMileage(String value) {        mMileage = value;    }    /**     * Get the value of the bean's <em>total mileage</em> field.     *     * @return The current value of the <em>total mileage</em> field     */    public String getTotalMileage() {        return mTotalMileage;    }    /**     * Set the value of the bean's <em>total mileage</em> field.     *     * @param value The value to be set onto the <em>total mileage</em> field     */    public void setTotalMileage(String value) {        mTotalMileage = value;    }    /**     * Get the value of the bean's <em>retired</em> field.     *     * @return The current value of the <em>retired</em> field     */    public String getRetired() {        return mRetired;    }    /**     * Get the value of the <em>retired</em> field as either 'Yes' or 'No'.     *     * @return 'Yes' if the <em>retired</em> fields represents some form of     *         'true' value, 'No' otherwise.     */    public String getRetiredAsYesNo() {        return getAsYesNo(getRetired());    }    /**     * Set the value of the bean's <em>retired</em> field.     *     * @param value The value to be set onto the <em>retired</em> field     */    public void setRetired(String value) {        mRetired = value;    }    /**     * Retrieve the form bean's values.     *     * @return A transfer object representing the for bean's state     */    public DTO getValues() {        DTO valueObject = super.getValues();        if (LOG.isDebugEnabled()) {            LOG.debug("getValues: Contents of the value object "                      + " (before) " + valueObject);        }        valueObject.setCanonicalId(Shoe.CANONICAL_ID);        valueObject.setValue(Shoe.FIELD_START_DATE, getStartDate());        valueObject.setValue(Shoe.FIELD_START_MILEAGE, getStartMileage());        valueObject.setValue(Shoe.FIELD_MILEAGE, getMileage());        valueObject.setValue(Shoe.FIELD_TOTAL_MILEAGE, getTotalMileage());        valueObject.setValue(Shoe.FIELD_RETIRED, getRetired());        if (LOG.isDebugEnabled()) {            LOG.debug("getValues: Contents of the value object "                      + " (after) " + valueObject);        }        return valueObject;    }    /**     * Update the form bean's values.     *     * @param valueObject Value object containing the new values     *                    to be applied to the form bean     */    public void setValues(DTO valueObject) {        if (LOG.isDebugEnabled()) {            LOG.debug("setValues: Contents of the value object "                      + valueObject);        }        super.setValues(valueObject);        setStartDate(valueObject.getValue(Shoe.FIELD_START_DATE));        setStartMileage(valueObject.getValue(Shoe.FIELD_START_MILEAGE));        setMileage(valueObject.getValue(Shoe.FIELD_MILEAGE));        setTotalMileage(valueObject.getValue(Shoe.FIELD_TOTAL_MILEAGE));        setRetired(valueObject.getValue(Shoe.FIELD_RETIRED));    }    /**     * Reset the state of the form bean.     *     * @param mapping The mapping used to select this instance     * @param request The servlet request we are processing     * @param container The current user's container object     * @see UserContainer#getUserName()     */    protected void reset(ActionMapping mapping, HttpServletRequest request,                         UserContainer container) {        super.reset(mapping, request, container);        String value = null;        if (Utilities.isBlank(getStartMileage())) {            value = ConstantValues.STRING_ZERO;            if (LOG.isDebugEnabled()) {                LOG.debug("reset: Resetting the start mileage to '"                          + value + "'");            }            setStartMileage(value);        }        // Handle cases where checkboxes are not checked        String flag = request.getParameter(Shoe.FIELD_RETIRED);        if (Utilities.isBlank(flag)) {            value = ConstantValues.STRING_FALSE;            if (LOG.isDebugEnabled()) {                LOG.debug("reset: Resetting the retired flag to '"                          + value + "'");            }            setRetired(value);        }    }}

⌨️ 快捷键说明

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