Package org.apache.tapestry5.model
Interface ComponentModel
- All Known Subinterfaces:
MutableComponentModel
- All Known Implementing Classes:
MutableComponentModelImpl
public interface ComponentModel
Defines a component in terms of its capabilities, parameters, sub-components, etc. During runtime, the
component model is immutable. During construction time, when the class is being transformed and loaded, the
model is mutable.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturns the resource corresponding to the class file for this component.The fully qualified class name of the component.Returns an alphabetically sorted list of the names of all formal parameters defined by this specific class (parameters inherited from base classes are not identified).Returns the ids of all embedded components defined within the component class (via theComponent
annotation), including those defined by any super-class.getEmbeddedComponentModel
(String componentId) Returns an embedded component defined by this component or by a super-class.getFieldPersistenceStrategy
(String fieldName) Returns the persistent strategy associated with the field.Returns a set of all the render phases that this model (including parent models) that are handled.Returns the name of the library that defines this component; this may be the empty string for an application page or component, or will be a name of a library (possibly including "core" for built-in components).org.slf4j.Logger
Returns object that will be used to log warnings and errors related to this component.Gets a meta value identified by the given key.Returns a list of the class names of mixins that are part of the component's implementation.String[]
getOrderForMixin
(String mixinClassName) getParameterModel
(String parameterName) Return a single parameter model by parameter name, or null if the parameter is not defined (is not a formal parameter).Returns an alphabetically sorted list of the names of all formal parameters.Returns the component model for this component's super-class, if it exists.Returns a list of the names of all persistent fields (within this class, or any super-class).boolean
Returns true if the model indicates that informal parameters, additional parameters beyond the formal parameter defined for the component, are supported.boolean
Relevant for pages only, indicates that the component handle theEventConstants.ACTIVATE
events with a catch all rulesboolean
handlesEvent
(String eventType) Determines if the component has an event handler for the indicated event name (case insensitive).boolean
isFormalParameter
(String parameterName) Returns true if the named parameter is formally defined (there's a ParameterModel).boolean
Relevant for component mixins only.boolean
isPage()
Is this a model of a page (rather than a component, mixin, or base-class)?boolean
Returns true if the modeled component is a root class, a component class whose parent class is not a component class.
-
Method Details
-
getLibraryName
Returns the name of the library that defines this component; this may be the empty string for an application page or component, or will be a name of a library (possibly including "core" for built-in components). Library names are defined by theLibraryMapping
contributions to theComponentClassResolver
service.- Returns:
- library name containing the component, or empty string for application components
- Since:
- 5.4
-
isPage
boolean isPage()Is this a model of a page (rather than a component, mixin, or base-class)?- Returns:
- true if a page
- Since:
- 5.3
-
getBaseResource
Returns the resource corresponding to the class file for this component. This is used to find related resources, such as the component's template and message catalog. -
getComponentClassName
The fully qualified class name of the component. -
getEmbeddedComponentIds
Returns the ids of all embedded components defined within the component class (via theComponent
annotation), including those defined by any super-class. -
getEmbeddedComponentModel
Returns an embedded component defined by this component or by a super-class.- Parameters:
componentId
- the id of the embedded component- Returns:
- the embedded component model, or null if no component exists with that id
-
getFieldPersistenceStrategy
Returns the persistent strategy associated with the field.- Parameters:
fieldName
-- Returns:
- the corresponding strategy, or the empty string
- Throws:
IllegalArgumentException
- if the named field is not marked as persistent
-
getLogger
org.slf4j.Logger getLogger()Returns object that will be used to log warnings and errors related to this component.- See Also:
-
getMixinClassNames
Returns a list of the class names of mixins that are part of the component's implementation. -
getParameterModel
Return a single parameter model by parameter name, or null if the parameter is not defined (is not a formal parameter). This may be a parameter defined by this component, or from a base class.- Parameters:
parameterName
- the name of the parameter (case is ignored)- Returns:
- the parameter model if found in this model or a parent model, or null if not found
-
isFormalParameter
Returns true if the named parameter is formally defined (there's a ParameterModel).- Parameters:
parameterName
- name of the parameter (case is ignored)- Since:
- 5.2.0
-
getParameterNames
Returns an alphabetically sorted list of the names of all formal parameters. This includes parameters defined by a base class. -
getDeclaredParameterNames
Returns an alphabetically sorted list of the names of all formal parameters defined by this specific class (parameters inherited from base classes are not identified). -
getPersistentFieldNames
Returns a list of the names of all persistent fields (within this class, or any super-class). The names are sorted alphabetically.- See Also:
-
isRootClass
boolean isRootClass()Returns true if the modeled component is a root class, a component class whose parent class is not a component class. We may in the future require that components only extend from Object.- Returns:
- true if a root class, false if a subclass
-
getSupportsInformalParameters
boolean getSupportsInformalParameters()Returns true if the model indicates that informal parameters, additional parameters beyond the formal parameter defined for the component, are supported. This is false in most cases, but may be set to true for specific classes (when theSupportsInformalParameters
annotation is present, or inherited from a super-class).- Returns:
- true if this component model supports informal parameters
-
getParentModel
Returns the component model for this component's super-class, if it exists. Remember that only classes in the correct packages, are considered component classes.- Returns:
- the parent class model, or null if this component's super class is not itself a component class
-
isMixinAfter
boolean isMixinAfter()Relevant for component mixins only. Indicates that the mixin behavior should occur after (not before) the component. Normally, this flag is set by the presence of theMixinAfter
annotation.- Returns:
- true if the mixin should operate after, not before, the component
-
getMeta
Gets a meta value identified by the given key. If the current model does not provide a value for the key, then the parent component model (if any) is searched.- Parameters:
key
- identifies the value to be accessed- Returns:
- the value for the key (possibly inherited from a parent model), or null
-
getHandledRenderPhases
Returns a set of all the render phases that this model (including parent models) that are handled. Render phases are represented by the corresponding annotation (BeginRender
,AfterRender
, etc.).- Returns:
- set of classes
- Since:
- 5.0.19, 5.1.0.0
-
handlesEvent
Determines if the component has an event handler for the indicated event name (case insensitive). This includes handlers in the component class itself, or its super-classes, but does not include event handlers supplied by implementation or instance mixins.- Parameters:
eventType
- name of event to check (case insensitive)- Returns:
- true if event handler present
-
getOrderForMixin
- Parameters:
mixinClassName
- class name of the mixin for which the ordering is desired- Returns:
- the ordering constraint(s) for the mixin, potentially null.
- Since:
- 5.2.0
-
handleActivationEventContext
boolean handleActivationEventContext()Relevant for pages only, indicates that the component handle theEventConstants.ACTIVATE
events with a catch all rules- Returns:
- true if the page implements catch all rules for the activate event context, or false otherwise
- Since:
- 5.4
- See Also:
-