1 14 package org.wings.template; 15 16 import org.wings.SComponent; 17 import org.wings.STemplateLayout; 18 import org.wings.io.Device; 19 import org.wings.template.parser.ParseContext; 20 import org.wings.template.parser.SpecialTagHandler; 21 22 import java.io.InputStream ; 23 import java.util.Iterator ; 24 import java.util.Map ; 25 26 32 abstract class TemplateTagHandler implements SpecialTagHandler { 33 long startPos; 34 long endPos; 35 Map properties; 36 String name; 37 38 42 public long getTagStart() { 43 return startPos; 44 } 45 46 50 54 public long getTagLength() { 55 return endPos - startPos; 56 } 57 58 64 public void executeTag(ParseContext context, InputStream input) 65 throws Exception { 66 TemplateParseContext tcontext = (TemplateParseContext) context; 67 Device sink = tcontext.getDevice(); 68 69 73 SComponent c = tcontext.getComponent(name); 74 if (c == null) { 75 sink.print("<!-- Template: '" + name + "' Component not given -->"); 76 } else { 77 if (properties.size() > 0) { 79 PropertyManager propManager = 80 STemplateLayout.getPropertyManager(c.getClass()); 81 82 if (propManager != null) { 83 Iterator iter = properties.keySet().iterator(); 84 while (iter.hasNext()) { 85 String key = (String ) iter.next(); 86 String value = (String ) properties.get(key); 87 propManager.setProperty(c, key, value); 89 } 90 } 91 } 92 c.write(sink); 93 } 94 input.skip(getTagLength()); 95 } 96 } 97 98 99 | Popular Tags |