Coverage Report - net.wotonomy.web.WOGenericElement
 
Classes in this File Line Coverage Branch Coverage Complexity
WOGenericElement
0% 
0% 
2.167
 
 1  
 /*
 2  
  Wotonomy: OpenStep design patterns for pure Java applications.
 3  
  Copyright (C) 2000 Blacksmith, Inc.
 4  
 
 5  
  This library is free software; you can redistribute it and/or
 6  
  modify it under the terms of the GNU Lesser General Public
 7  
  License as published by the Free Software Foundation; either
 8  
  version 2.1 of the License, or (at your option) any later version.
 9  
 
 10  
  This library is distributed in the hope that it will be useful,
 11  
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
  Lesser General Public License for more details.
 14  
 
 15  
  You should have received a copy of the GNU Lesser General Public
 16  
  License along with this library; if not, see http://www.gnu.org
 17  
  */
 18  
 
 19  
 package net.wotonomy.web;
 20  
 
 21  
 import net.wotonomy.foundation.NSArray;
 22  
 import net.wotonomy.foundation.NSDictionary;
 23  
 
 24  
 /**
 25  
  * Used to generate any HTML element dynamically. It only creates the opening tag without a closing tag.
 26  
  * To generate HTML elements that have opening and closing tags, as well as some content in between,
 27  
  * use WOGenericContainer instead.
 28  
  * @author michael@mpowers.net
 29  
  * @author $Author: cgruber $
 30  
  * @version $Revision: 905 $
 31  
  */
 32  0
 public class WOGenericElement extends WODynamicElement {
 33  
 
 34  0
     static NSArray bindings = new NSArray( new Object[] 
 35  0
         { "elementName", "omitTags", "elementID", "otherTagString",
 36  0
           "formValue", "formValues", "invokeAction" } );
 37  
           
 38  
     public WOGenericElement() {
 39  0
         super();
 40  0
     }
 41  
 
 42  
     public WOGenericElement(String n, NSDictionary m, WOElement t) {
 43  0
         super(n, m, t);
 44  0
     }
 45  
 
 46  
     public String elementName(WOContext c) {
 47  0
         String x = (String)valueForProperty("elementName", c.component());
 48  0
         if (x != null)
 49  0
             return x;
 50  0
         return c.elementID();
 51  
     }
 52  
 
 53  
     public void takeValuesFromRequest(WORequest r, WOContext c) {
 54  0
         if ( c.elementID().equals( c.senderID() ) )
 55  
         {
 56  
             Object value;
 57  0
             value = r.formValueForKey( c.elementID() );
 58  0
             setValueForProperty( "formValue", value, c.component() );
 59  0
             value = r.formValuesForKey( c.elementID() );
 60  0
             setValueForProperty( "formValues", value, c.component() );
 61  
         }
 62  0
     }
 63  
 
 64  
     public WOActionResults invokeAction(WORequest r, WOContext c) 
 65  
     {
 66  0
         WOActionResults result = null;
 67  0
         String action = stringForProperty( "invokeAction", c.component() );
 68  0
         if ( action != null && c.elementID().equals( c.senderID() ) )
 69  
         {
 70  0
             result = c.component().performAction( action );
 71  
         }
 72  0
         return result;
 73  
     }
 74  
     
 75  
     public void appendToResponse(WOResponse r, WOContext c) {
 76  0
         WOComponent component = c.component();
 77  0
         if ( !booleanForProperty( "omitTags", component ) )
 78  
         {
 79  0
             r.appendContentString("<");
 80  0
             r.appendContentString(elementName(c));
 81  0
             String other = stringForProperty( "otherTagString", component );
 82  0
             if ( other != null )
 83  
             {
 84  0
                 r.appendContentString( " " );
 85  0
                 r.appendContentString( other );
 86  
             }
 87  0
             String add = additionalHTMLProperties(component, bindings);
 88  0
             if (add.length() > 0)
 89  0
                 r.appendContentString(add);
 90  0
             r.appendContentString(">");
 91  
         }
 92  0
         setValueForProperty( "elementID", c.elementID(), component );
 93  0
     }
 94  
 
 95  
 }