Clover coverage report - Code Coverage for tapestry release 3.1-alpha-1
Coverage timestamp: Mon Feb 21 2005 09:16:14 EST
file stats: LOC: 109   Methods: 1
NCLOC: 42   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
Submit.java 0% 0% 0% 0%
coverage
 1   
 // Copyright 2004, 2005 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.tapestry.form;
 16   
 
 17   
 import org.apache.tapestry.IActionListener;
 18   
 import org.apache.tapestry.IBinding;
 19   
 import org.apache.tapestry.IForm;
 20   
 import org.apache.tapestry.IMarkupWriter;
 21   
 import org.apache.tapestry.IRequestCycle;
 22   
 
 23   
 
 24   
 /**
 25   
  *  Implements a component that manages an HTML <input type=submit> form element.
 26   
  * 
 27   
  *  [<a href="../../../../../ComponentReference/Submit.html">Component Reference</a>]
 28   
  *
 29   
  *  <p>This component is generally only used when the form has multiple
 30   
  *  submit buttons, and it is important for the application to know
 31   
  *  which one was pressed.  You may also want to use
 32   
  *  {@link ImageSubmit} which accomplishes much the same thing, but uses
 33   
  *  a graphic image instead.
 34   
  *
 35   
  *
 36   
  *  @author Howard Lewis Ship
 37   
  * 
 38   
  **/
 39   
 
 40   
 public abstract class Submit extends AbstractFormComponent{
 41   
 
 42  0
     protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
 43   
     {
 44   
 
 45  0
         IForm form = getForm(cycle);
 46   
         
 47  0
         boolean rewinding = form.isRewinding();
 48   
 
 49  0
         String name = form.getElementId(this);
 50   
 
 51  0
         if (rewinding)
 52   
         {
 53   
             // Don't bother doing anything if disabled.
 54   
 
 55  0
             if (isDisabled())
 56  0
                 return;
 57   
 
 58   
             // How to know which Submit button was actually
 59   
             // clicked?  When submitted, it produces a request parameter
 60   
             // with its name and value (the value serves double duty as both
 61   
             // the label on the button, and the parameter value).
 62   
 
 63  0
             String value = cycle.getRequestContext().getParameter(name);
 64   
 
 65   
             // If the value isn't there, then this button wasn't
 66   
             // selected.
 67   
 
 68  0
             if (value == null)
 69  0
                 return;
 70   
 
 71  0
             IBinding selectedBinding = getBinding("selected");
 72   
 
 73  0
             if (selectedBinding != null)
 74  0
                 selectedBinding.setObject(getTag());
 75   
 
 76  0
             IActionListener listener = getListener();
 77   
 
 78  0
             if (listener != null)
 79  0
                 listener.actionTriggered(this, cycle);
 80   
 
 81  0
             return;
 82   
         }
 83   
 
 84  0
         writer.beginEmpty("input");
 85  0
         writer.attribute("type", "submit");
 86  0
         writer.attribute("name", name);
 87   
 
 88  0
         if (isDisabled())
 89  0
             writer.attribute("disabled", "disabled");
 90   
 
 91  0
         String label = getLabel();
 92   
 
 93  0
         if (label != null)
 94  0
             writer.attribute("value", label);
 95   
 
 96  0
         renderInformalParameters(writer, cycle);
 97   
 
 98  0
         writer.closeTag();
 99   
     }
 100   
 
 101   
     public abstract String getLabel();
 102   
 
 103   
     public abstract boolean isDisabled();
 104   
 
 105   
     public abstract IActionListener getListener();
 106   
 
 107   
     public abstract Object getTag();
 108   
 
 109   
 }