Clover coverage report - angkor - 0.4
Coverage timestamp: ti okt 15 2002 22:32:48 CEST
file stats: LOC: 96   Methods: 10
NCLOC: 66   Classes: 1
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
CheckboxInput.java 0% 0% 0% 0%
 1   
 /*
 2   
  * Angkor Web Framework
 3   
  *
 4   
  * Distributable under LGPL license.
 5   
  * See terms of license at gnu.org.
 6   
  */
 7   
 
 8   
 package com.tirsen.angkor.widget;
 9   
 
 10   
 import com.tirsen.angkor.RenderContext;
 11   
 import com.tirsen.angkor.Component;
 12   
 
 13   
 import java.io.IOException;
 14   
 
 15   
 /**
 16   
  * @author $Author: tirsen $
 17   
  * @version $Revision: 1.5 $
 18   
  * <BR>
 19   
  * $Id: CheckboxInput.java,v 1.5 2002/10/13 19:59:23 tirsen Exp $
 20   
  */
 21   
 public class CheckboxInput extends Component
 22   
 {
 23   
     private ValueModel model;
 24   
     private TextLabel prompt;
 25   
 
 26  0
     public CheckboxInput(String id)
 27   
     {
 28  0
         super(id);
 29   
     }
 30   
 
 31  0
     public CheckboxInput()
 32   
     {
 33   
     }
 34   
 
 35  0
     public CheckboxInput(String prompt, ValueModel model)
 36   
     {
 37  0
         setPrompt(prompt);
 38  0
         this.model = model;
 39   
     }
 40   
 
 41   
     /**
 42   
      * @param model a ValueModel that return values of type Boolean.
 43   
      */
 44  0
     public void setModel(ValueModel model)
 45   
     {
 46  0
         this.model = model;
 47   
     }
 48   
 
 49  0
     public void setPrompt(TextLabel prompt)
 50   
     {
 51  0
         this.prompt = prompt;
 52   
     }
 53   
 
 54  0
     public void setPrompt(String promptText)
 55   
     {
 56  0
         prompt = new TextLabel();
 57  0
         prompt.setLabel(promptText);
 58   
     }
 59   
 
 60  0
     public void setVisible(boolean visible)
 61   
     {
 62  0
         super.setVisible(visible);
 63  0
         prompt.setVisible(visible);
 64   
     }
 65   
 
 66  0
     public boolean isParsing()
 67   
     {
 68  0
         return true;
 69   
     }
 70   
 
 71  0
     public void parse(RenderContext context)
 72   
     {
 73  0
         super.parse(context);
 74  0
         if (isVisible() && model != null && !model.isReadOnly())
 75   
         {
 76  0
             boolean value = "on".equals(context.getRequestParameter(getId()));
 77  0
             model.setValue(new Boolean(value));
 78   
         }
 79   
     }
 80   
 
 81  0
     public void render(RenderContext context) throws IOException
 82   
     {
 83  0
         if (isVisible())
 84   
         {
 85  0
             String checked = "";
 86  0
             if (model != null && ((Boolean) model.getValue()).booleanValue())
 87   
             {
 88  0
                 checked = " checked ";
 89   
             }
 90  0
             context.startTag("INPUT type=\"checkbox\" name=\"" + uniqueId(context) + "\"" + checked);
 91  0
             if (prompt != null) prompt.render(context);
 92  0
             context.registerParsingComponent(this);
 93   
         }
 94   
     }
 95   
 }
 96