You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by dg...@apache.org on 2003/05/15 04:33:41 UTC

cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html FormTag.java

dgraham     2003/05/14 19:33:41

  Modified:    src/share/org/apache/struts/taglib/html FormTag.java
  Log:
  Refactored form bean initialization out of doStartTag() into its own method.
  
  Revision  Changes    Path
  1.47      +20 -13    jakarta-struts/src/share/org/apache/struts/taglib/html/FormTag.java
  
  Index: FormTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/FormTag.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- FormTag.java	23 Apr 2003 00:01:18 -0000	1.46
  +++ FormTag.java	15 May 2003 02:33:40 -0000	1.47
  @@ -88,9 +88,9 @@
    * @author Craig R. McClanahan
    * @author Martin Cooper
    * @author James Turner
  + * @author David Graham
    * @version $Revision$ $Date$
    */
  -
   public class FormTag extends TagSupport {
   
       // ----------------------------------------------------- Instance Variables
  @@ -503,7 +503,7 @@
       public int doStartTag() throws JspException {
   
           // Look up the form bean name, scope, and type if necessary
  -        lookup();
  +        this.lookup();
   
           // Create an appropriate "form" element based on our parameters
           StringBuffer results = new StringBuffer();
  @@ -512,17 +512,28 @@
   
           results.append(this.renderToken());
   
  -        // Print this field to our output writer
           ResponseUtils.write(pageContext, results.toString());
   
           // Store this tag itself as a page attribute
           pageContext.setAttribute(Constants.FORM_KEY, this, PageContext.REQUEST_SCOPE);
   
  -        // Locate or create the bean associated with our form
  +        this.initFormBean();
  +
  +        return (EVAL_BODY_INCLUDE);
  +
  +    }
  +
  +    /**
  +     * Locate or create the bean associated with our form.
  +     * @throws JspException
  +     * @since Struts 1.1
  +     */
  +    protected void initFormBean() throws JspException {
           int scope = PageContext.SESSION_SCOPE;
  -        if ("request".equals(beanScope)) {
  +        if ("request".equalsIgnoreCase(beanScope)) {
               scope = PageContext.REQUEST_SCOPE;
           }
  +        
           Object bean = pageContext.getAttribute(beanName, scope);
           if (bean == null) {
               if (type != null) {
  @@ -554,10 +565,6 @@
               pageContext.setAttribute(beanName, bean, scope);
           }
           pageContext.setAttribute(Constants.BEAN_KEY, bean, PageContext.REQUEST_SCOPE);
  -
  -        // Continue processing this page
  -        return (EVAL_BODY_INCLUDE);
  -
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org