Package org.apache.struts.tiles
Class ComponentDefinition
java.lang.Object
org.apache.struts.tiles.ComponentDefinition
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
XmlDefinition
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.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Controller name type.Attributes defined for the component.protected String
Associated Controller URL or classname, if definedstatic final String
Controller name type.protected String
Associated Controller typename, if controllerName defined.protected String
Definition nameprotected String
Component / template path (URL).protected String
Role associated to definition.static final String
Controller name type. -
Constructor Summary
ConstructorDescriptionConstructor.Constructor.ComponentDefinition
(ComponentDefinition definition) Copy Constructor.ComponentDefinition
(XmlDefinition definition) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic Controller
createController
(String name, String controllerType) Create a new instance of controller named in parameter.static Controller
createControllerFromClassname
(String classname) Create a controller from specified classname.getAttribute
(String key) Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.Access method for the attributes property.Get associated controller local URL.Get controller instance.Get associated controller type.getName()
Access method for the name property.Get or create controller.getPage()
Access method for the path property.getPath()
Access method for the path property.getRole()
Access method for the role property.Access method for the template property.void
Put an attribute in component / template definition.void
Put an attribute in template definition.void
Put an attribute in template definition.void
Put an attribute in template definition.void
putAttribute
(String key, Object value) Put a new attribute in this componentvoid
setController
(String url) Set associated controller URL.void
setControllerClass
(String controller) Set associated controller name as a classtype, and controller type as "classname".void
setControllerInstance
(Controller controller) Set controller.void
setControllerType
(String controllerType) Set associated controller type.void
setControllerUrl
(String controller) Set associated controller name as an url, and controller type as "url".void
Sets the value of the name property.void
Sets the value of the path property.void
Sets the value of the path property.void
Sets the value of the role property.void
setTemplate
(String template) Sets the value of the template property.toString()
Returns a description of the attributes.
-
Field Details
-
name
Definition name -
path
Component / template path (URL). -
attributes
Attributes defined for the component. -
role
Role associated to definition. -
controller
Associated Controller URL or classname, if defined -
controllerType
Associated Controller typename, if controllerName defined. Can be CONTROLLER, ACTION or URL, or null. -
URL
Controller name type.- See Also:
-
CONTROLLER
Controller name type.- See Also:
-
ACTION
Controller name type.- See Also:
-
-
Constructor Details
-
ComponentDefinition
public ComponentDefinition()Constructor. -
ComponentDefinition
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
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.- Throws:
InstantiationException
- if an error occur while instantiating Controller : (classname can't be instantiated, Illegal access with instantiated class, Error while instantiating class, classname can't be instantiated.
-
ComponentDefinition
Constructor.
-
-
Method Details
-
getName
Access method for the name property.- Returns:
- the current value of the name property
-
setName
Sets the value of the name property.- Parameters:
aName
- the new value of the name property
-
getPage
Access method for the path property.- Returns:
- The current value of the path property.
-
setPage
Sets the value of the path property.- Parameters:
page
- the new value of the path property
-
getPath
Access method for the path property.- Returns:
- the current value of the path property
-
setPath
Sets the value of the path property.- Parameters:
aPath
- the new value of the path property
-
getTemplate
Access method for the template property. Same as getPath()- Returns:
- the current value of the template property
-
setTemplate
Sets the value of the template property. Same as setPath()- Parameters:
template
- the new value of the path property
-
getRole
Access method for the role property.- Returns:
- the current value of the role property
-
setRole
Sets the value of the role property.- Parameters:
role
- the new value of the path property
-
getAttributes
Access method for the attributes property. If there is no attributes, return an empty map.- Returns:
- the current value of the attributes property
-
getAttribute
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.- Returns:
- requested attribute or null if not found
-
putAttribute
Put a new attribute in this component- Parameters:
key
- String key for attributevalue
- Attibute value.
-
put
Put an attribute in component / template definition. Attribute can be used as content for tag get.- Parameters:
name
- Attribute namecontent
- Attribute value
-
put
Put an attribute in template definition. Attribute can be used as content for tag get.- Parameters:
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 included
-
put
Put an attribute in template definition. Attribute can be used as content for tag get.- Parameters:
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.
-
put
Put an attribute in template definition. Attribute can be used as content for tag get.- Parameters:
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.
-
toString
Returns a description of the attributes. -
getControllerType
Get associated controller type. Type denote a fully qualified classname. -
setControllerType
Set associated controller type. Type denote a fully qualified classname.- Parameters:
controllerType
- Typeof associated controller
-
setControllerUrl
Set associated controller name as an url, and controller type as "url". Name must be an url (not checked). Convenience method.- Parameters:
controller
- Controller url
-
setControllerClass
Set associated controller name as a classtype, and controller type as "classname". Name denote a fully qualified classname Convenience method.- Parameters:
controller
- Controller classname.
-
getController
Get associated controller local URL. URL should be local to webcontainer in order to allow request context followup. URL comes as a string. -
setController
Set associated controller URL. URL should be local to webcontainer in order to allow request context followup. URL is specified as a string.- Parameters:
url
- Url called locally
-
getControllerInstance
Get controller instance.- Returns:
- controller instance.
-
getOrCreateController
Get or create controller. Get controller, create it if necessary.- Returns:
- controller if controller or controllerType is set, null otherwise.
- Throws:
InstantiationException
- if an error occur while instanciating Controller : (classname can't be instanciated, Illegal access with instanciated class, Error while instanciating class, classname can't be instanciated.
-
setControllerInstance
Set controller. -
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.- Parameters:
name
- Controller name (classname, url, ...)controllerType
- Expected Controller type- Returns:
- org.apache.struts.tiles.Controller
- Throws:
InstantiationException
- if an error occur while instanciating Controller : (classname can't be instanciated, Illegal access with instanciated class, Error while instanciating class, classname can't be instanciated.
-
createControllerFromClassname
public static Controller createControllerFromClassname(String classname) throws InstantiationException Create a controller from specified classname.- Parameters:
classname
- Controller classname.- Returns:
- org.apache.struts.tiles.Controller
- Throws:
InstantiationException
- if an error occur while instanciating Controller: (classname can't be instantiated, Illegal access with instantiated class, Error while instantiating class, classname can't be instantiated.
-