1 package org.sapia.gumby.tags; 2 3 import org.sapia.gumby.RenderContext; 4 import org.sapia.gumby.factory.ContextAware; 5 import org.sapia.gumby.factory.ParentAware; 6 import org.sapia.gumby.tags.support.ScopeIdParser; 7 import org.sapia.util.xml.confix.ConfigurationException; 8 import org.sapia.util.xml.confix.NullObject; 9 import org.sapia.util.xml.confix.ObjectCreationCallback; 10 11 26 public class Register implements ContextAware, ParentAware, 27 ObjectCreationCallback, NullObject { 28 29 private RenderContext _context; 30 private Object _parent; 31 private String _id; 32 33 public void setId(String id) { 34 _id = id; 35 } 36 37 40 public void handleContext(RenderContext context) { 41 _context = context; 42 } 43 44 47 public void handleParent(Object parent) { 48 _parent = parent; 49 } 50 51 54 public Object onCreate() throws ConfigurationException { 55 if(_id == null) { 56 throw new ConfigurationException("id not specified"); 57 } 58 String [] idAndScope = ScopeIdParser.parse(_id); 59 if(idAndScope.length == 0) { 60 _context.getSettings().getBindings().put(_id, _parent); 61 } else if(idAndScope.length == 1) { 62 _context.getSettings().getBindings().put(idAndScope[ScopeIdParser.ID], 63 _parent); 64 } else { 65 _context.getEnv().put(idAndScope[ScopeIdParser.ID], _parent, 66 idAndScope[ScopeIdParser.SCOPE]); 67 } 68 return this; 69 } 70 71 } 72 | Popular Tags |