Definition of a template / component attributes.
Attributes of a component can be defined with the help of this class.
An instance of this class can be used as a bean, and passed to 'insert' tag.
ACTION
public static final String ACTION
Controller name type.
CONTROLLER
public static final String CONTROLLER
Controller name type.
URL
public static final String URL
Controller name type.
attributes
protected Map attributes
Attributes defined for the component.
controller
protected String controller
Associated Controller URL or classname, if defined
controllerInstance
private Controller controllerInstance
Controller associated to Definition.
Lazy creation : only on first request
controllerType
protected String controllerType
Associated Controller typename, if controllerName defined.
Can be CONTROLLER, ACTION or URL, or null.
log
protected static Log log
Commons Logging instance.
name
protected String name
Definition name
path
protected String path
Component / template path (URL).
role
protected String role
Role associated to definition.
ComponentDefinition
public ComponentDefinition()
Constructor.
ComponentDefinition
public ComponentDefinition(String name,
String path,
Map attributes)
Constructor.
ComponentDefinition
public ComponentDefinition(ComponentDefinition definition)
Copy Constructor.
Create a new definition initialized with parent definition.
Do a shallow copy : attributes are shared between copies, but not the Map
containing attributes.
ComponentDefinition
public ComponentDefinition(XmlDefinition definition)
Constructor.
Create a new definition initialized from a RawDefinition.
Raw definitions are used to read definition from a data source (xml file, db, ...).
A RawDefinition mainly contains properties of type String, while Definition
contains more complex type (ex : Controller).
Do a shallow copy : attributes are shared between objects, but not the Map
containing attributes.
OO Design issues : Actually RawDefinition (XmlDefinition) extends ComponentDefinition.
This must not be the case. I have do it because I am lazy.
createController
public static Controller createController(String name,
String controllerType)
throws InstantiationException
Create a new instance of controller named in parameter.
If controllerType is specified, create controller accordingly.
Otherwise, if name denote a classname, create an instance of it. If class is
subclass of org.apache.struts.action.Action, wrap controller
appropriately.
Otherwise, consider name as an url.
name
- Controller name (classname, url, ...)controllerType
- Expected Controller type
- org.apache.struts.tiles.Controller
createControllerFromClassname
public static Controller createControllerFromClassname(String classname)
throws InstantiationException
Create a controller from specified classname
classname
- Controller classname.
- org.apache.struts.tiles.Controller
getAttribute
public Object getAttribute(String key)
Returns the value of the named attribute as an Object, or null if no
attribute of the given name exists.
- requested attribute or null if not found
getAttributes
public Map getAttributes()
Access method for the attributes property.
If there is no attributes, return an empty map.
- the current value of the attributes property
getController
public String getController()
Get associated controller local URL.
URL should be local to webcontainer in order to allow request context followup.
URL comes as a string.
getControllerInstance
public Controller getControllerInstance()
Get controller instance.
getControllerType
public String getControllerType()
Get associated controller type.
Type denote a fully qualified classname.
getName
public String getName()
Access method for the name property.
- the current value of the name property
getOrCreateController
public Controller getOrCreateController()
throws InstantiationException
Get or create controller.
Get controller, create it if necessary.
- controller if controller or controllerType is set, null otherwise.
getPage
public String getPage()
Access method for the path property.
- The current value of the path property.
getPath
public String getPath()
Access method for the path property.
- the current value of the path property
getRole
public String getRole()
Access method for the role property.
- the current value of the role property
getTemplate
public String getTemplate()
Access method for the template property.
Same as getPath()
- the current value of the template property
put
public void put(String name,
Object content)
Put an attribute in component / template definition.
Attribute can be used as content for tag get.
name
- Attribute namecontent
- Attribute value
put
public void put(String name,
Object content,
String type,
String role)
Put an attribute in template definition.
Attribute can be used as content for tag get.
name
- Attribute namecontent
- Attribute valuetype
- attribute type: template, string, definitionrole
- Determine if content is used by get tag. If user is in role, content is used.
put
public void put(String name,
Object content,
boolean direct)
Put an attribute in template definition.
Attribute can be used as content for tag get.
name
- Attribute namecontent
- Attribute value ???direct
- Determines how content is handled by get tag: true means content is printed directly; false, the default, means content is included
put
public void put(String name,
Object content,
boolean direct,
String role)
Put an attribute in template definition.
Attribute can be used as content for tag get.
name
- Attribute namecontent
- Attribute valuedirect
- Determines how content is handled by get tag: true means content is printed directly; false, the default, means content is includedrole
- Determine if content is used by get tag. If user is in role, content is used.
putAttribute
public void putAttribute(String key,
Object value)
Put a new attribute in this component
key
- String key for attributevalue
- Attibute value.
setController
public void setController(String url)
Set associated controller URL.
URL should be local to webcontainer in order to allow request context followup.
URL is specified as a string.
setControllerClass
public void setControllerClass(String controller)
Set associated controller name as a classtype, and controller
type as "classname".
Name denote a fully qualified classname
Convenience method.
controller
- Controller classname.
setControllerInstance
public void setControllerInstance(Controller controller)
Set controller.
setControllerType
public void setControllerType(String controllerType)
Set associated controller type.
Type denote a fully qualified classname.
controllerType
- Typeof associated controller
setControllerUrl
public void setControllerUrl(String controller)
Set associated controller name as an url, and controller
type as "url".
Name must be an url (not checked).
Convenience method.
controller
- Controller url
setName
public void setName(String aName)
Sets the value of the name property.
aName
- the new value of the name property
setPage
public void setPage(String page)
Sets the value of the path property.
page
- the new value of the path property
setPath
public void setPath(String aPath)
Sets the value of the path property.
aPath
- the new value of the path property
setRole
public void setRole(String role)
Sets the value of the role property.
role
- the new value of the path property
setTemplate
public void setTemplate(String template)
Sets the value of the template property.
Same as setPath()
template
- the new value of the path property
toString
public String toString()
Returns a description of the attributes.