📄 hasrunneridformbean.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.Route;import net.sf.irunninglog.servlet.UserContainer;import net.sf.irunninglog.util.DTO;import net.sf.irunninglog.util.Utilities;/** * Value bean representation of any object with a <em>runner id</em> field. * Contains any logic needed to access, udpate, or reset the field's value. * * @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 HasRunnerIdFormBean extends ValueBean { /** <code>Log</code> instance for this class. */ private static final Log LOG = LogFactory.getLog(HasRunnerIdFormBean.class); /** The bean's <em>runner id</em> field. */ private String mRunnerId; /** * Get the value of the bean's <em>runner id</em> field. * * @return The current value of the <em>runner id</em> field */ public String getRunnerId() { return mRunnerId; } /** * Set the value of the bean's <em>runner id</em> field. * * @param value The value to be set onto the <em>runner id</em> field */ public void setRunnerId(String value) { mRunnerId = 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(Route.FIELD_RUNNER_ID, getRunnerId()); 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); setRunnerId(valueObject.getValue(Route.FIELD_RUNNER_ID)); } /** * 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); if (Utilities.isBlank(getRunnerId())) { String value = container.getUserName(); if (LOG.isDebugEnabled()) { LOG.debug("reset: Resetting the runner id to '" + value + "'"); } setRunnerId(value); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -