1 15 package org.apache.tapestry.binding; 16 17 import org.apache.hivemind.Location; 18 import org.apache.hivemind.util.Defense; 19 import org.apache.tapestry.BindingException; 20 import org.apache.tapestry.IAsset; 21 import org.apache.tapestry.IComponent; 22 import org.apache.tapestry.coerce.ValueConverter; 23 24 30 public class AssetBinding extends AbstractBinding 31 { 32 private final IComponent _component; 33 34 private final String _assetName; 35 36 public AssetBinding(String description, ValueConverter valueConverter, Location location, 37 IComponent component, String assetName) 38 { 39 super(description, valueConverter, location); 40 41 Defense.notNull(component, "component"); 42 Defense.notNull(assetName, "assetName"); 43 44 _component = component; 45 _assetName = assetName; 46 } 47 48 public Object getObject() 49 { 50 IAsset result = _component.getAsset(_assetName); 51 52 if (result == null) 53 throw new BindingException(BindingMessages.missingAsset(_component, _assetName), 54 _component, getLocation(), this, null); 55 56 return result; 57 } 58 59 public Object getComponent() 60 { 61 return _component; 62 } 63 } | Popular Tags |