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

📄 referencedataformbean.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.ReferenceData;import net.sf.irunninglog.servlet.UserContainer;import net.sf.irunninglog.util.ConstantValues;import net.sf.irunninglog.util.DTO;import net.sf.irunninglog.util.Utilities;/** * Value bean representation of any application reference data.  This class * provides the fields common to all application reference data, along with the * logic needed to access, update, and reset those fields' values. * * @author <a href="mailto:allan_e_lewis@yahoo.com">Allan Lewis</a> * @version $Revision: 1.1.1.1 $ $Date: 2005/06/23 01:49:01 $ * @since iRunningLog 1.0 */public abstract class ReferenceDataFormBean extends HasGeneratedIdFormBean {    /** <code>Log</code> instance for this class. */    private static final Log LOG =                                LogFactory.getLog(ReferenceDataFormBean.class);    /** The bean's <em>description</em> field. */    private String mDescription;    /** The bean's <em>default</em> field. */    private String mDefault;    /**     * Get the value of the bean's <em>description</em> field.     *     * @return The current value of the <em>description</em> field     */    public String getDescription() {        return mDescription;    }    /**     * Set the value of the bean's <em>description</em> field.     *     * @param value The value to be set onto the <em>description</em> field     */    public void setDescription(String value) {        mDescription = value;    }    /**     * Get the value of the bean's <em>default</em> field.     *     * @return The current value of the <em>default</em> field     */    public String getDefault() {        return mDefault;    }    /**     * Get the value of the <em>default</em> field as either 'Yes' or 'No'.     *     * @return 'Yes' if the <em>default</em> fields represents some form of     *         'true' value, 'No' otherwise.     */    public String getDefaultAsYesNo() {        return getAsYesNo(getDefault());    }    /**     * Set the value of the bean's <em>default</em> field.     *     * @param value The value to be set onto the <em>default</em> field     */    public void setDefault(String value) {        mDefault = 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.setValue(ReferenceData.FIELD_DESCRIPTION, getDescription());        valueObject.setValue(ReferenceData.FIELD_DEFAULT, getDefault());        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);        setDescription(valueObject.getValue(ReferenceData.FIELD_DESCRIPTION));        setDefault(valueObject.getValue(ReferenceData.FIELD_DEFAULT));    }    /**     * Reset the state of the form bean.  This will reset the value of the     * <em>id</em> field if it is null (using the value from     * <code>UserContainer.getUserName()</code>).     *     * @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;        // Handle cases where checkboxes are not checked        String flag = request.getParameter(ReferenceData.FIELD_DEFAULT);        if (Utilities.isBlank(flag)) {            value = ConstantValues.STRING_FALSE;            if (LOG.isDebugEnabled()) {                LOG.debug("reset: Resetting the default flag to '"                          + value + "'");            }            setDefault(value);        }    }}

⌨️ 快捷键说明

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