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.view.View; 6 import org.sapia.util.xml.confix.NullObject; 7 import org.sapia.util.xml.confix.ObjectWrapperIF; 8 9 24 public class ViewTag implements ContextAware, ObjectWrapperIF, NullObject { 25 26 private View _view; 27 private RenderContext _context; 28 29 public void setScope(String scope) { 30 try { 31 _view = (View) _context.getEnv().getScope(scope); 32 } catch(ClassCastException e) { 33 throw new IllegalStateException ("Scope '" + scope 34 + "' not an instance of " + View.class.getName() + ": " 35 + _context.getEnv().getScope(scope).getClass().getName()); 36 } 37 if(_view == null) { 38 _view = _context.createView(scope); 39 } 40 } 41 42 45 public void handleContext(RenderContext context) { 46 _context = context; 47 } 48 49 52 public Object getWrappedObject() { 53 if(_view == null) { 54 throw new IllegalStateException ("View not set"); 55 } 56 return _view; 57 } 58 } 59 | Popular Tags |