001: // Copyright 2006, 2007 The Apache Software Foundation
002: //
003: // Licensed under the Apache License, Version 2.0 (the "License");
004: // you may not use this file except in compliance with the License.
005: // You may obtain a copy of the License at
006: //
007: // http://www.apache.org/licenses/LICENSE-2.0
008: //
009: // Unless required by applicable law or agreed to in writing, software
010: // distributed under the License is distributed on an "AS IS" BASIS,
011: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: // See the License for the specific language governing permissions and
013: // limitations under the License.
014:
015: package org.apache.tapestry;
016:
017: import org.apache.tapestry.ioc.AnnotationProvider;
018: import org.apache.tapestry.ioc.Messages;
019: import org.apache.tapestry.ioc.Resource;
020: import org.apache.tapestry.model.ComponentModel;
021: import org.apache.tapestry.runtime.Component;
022:
023: /**
024: * Provides a component instance with the resources provided by the framework. In many
025: * circumstances, the resources object can be considered the component itself; in others, it is the
026: * {@link #getComponent() component property}, and instance of a class provided by the application
027: * developer (though transformed in many ways while being loaded) that is the true component. In
028: * reality, it is the combination of the resources object with the lifecycle instance.
029: */
030: public interface ComponentResources extends ComponentResourcesCommon {
031: /**
032: * Returns the base resource for the component, which will represent the class's location within
033: * the classpath (this is used to resolve relative assets).
034: */
035: Resource getBaseResource();
036:
037: /** Returns the component model object that defines the behavior of the component. */
038: ComponentModel getComponentModel();
039:
040: /**
041: * Returns the component this object provides resources for.
042: */
043: Component getComponent();
044:
045: /**
046: * Returns the component which contains this component, or null for the root component.
047: */
048: Component getContainer();
049:
050: /**
051: * Returns the {@link ComponentResources} for the container, or null if the this is the root
052: * component (that has no container). As a special case, for a mixin, this returns the core
053: * component's resources.
054: */
055: ComponentResources getContainerResources();
056:
057: /**
058: * Returns the {@link Messages} from the container, or null if this is the root component (with
059: * no container). As a special case, for a mixin, this return the core component's messages.
060: */
061: Messages getContainerMessages();
062:
063: /**
064: * Returns the page that contains this component. Technically, the page itself is an internal
065: * object in Tapestry and this returns the root component of the actual page, but from an
066: * application developer point of view, this is the page.
067: */
068: Component getPage();
069:
070: /**
071: * Returns an embedded component, given the component's id.
072: *
073: * @param embeddedId
074: * selects the embedded component (case is ignored)
075: * @throws IllegalArgumentException
076: * if this component does not contain a component with the given id
077: */
078:
079: Component getEmbeddedComponent(String embeddedId);
080:
081: /** Returns true if the named parameter is bound, false if not. */
082: boolean isBound(String parameterName);
083:
084: /**
085: * Indentifies all parameters that are not formal parameters and writes each as a
086: * attribute/value pair into the current element of the markup writer.
087: *
088: * @param writer
089: * to which {@link MarkupWriter#attributes(Object[]) attributes} will be written
090: */
091: void renderInformalParameters(MarkupWriter writer);
092:
093: /** Returns the message catalog for this component. */
094: Messages getMessages();
095:
096: /**
097: * Returns the actual type of the bound parameter, or null if the parameter is not bound. This
098: * is primarily used with property bindings, and is used to determine the actual type of the
099: * property, rather than the type of parameter (remember that type coercion automatically
100: * occurs, which can mask significant differences between the parameter type and the bound
101: * property type).
102: *
103: * @see Binding#getBindingType()
104: * @param parameterName
105: * used to select the parameter (case is ignored)
106: * @return the type of the bound parameter, or null if the parameter is not bound
107: */
108: Class getBoundType(String parameterName);
109:
110: /**
111: * Returns an annotation provider, used to obtain annotations related to the parameter.
112: *
113: * @param parameterName
114: * used to select the parameter (case is ignored)
115: * @return the annotation provider, or null if the parameter is not bound
116: */
117: AnnotationProvider getAnnotationProvider(String parameterName);
118:
119: /**
120: * Used to access an informal parameter that's a Block.
121: *
122: * @param parameterName
123: * the name of the informal parameter (case is ignored)
124: * @return the informal Block parameter, or null if not bound
125: */
126: Block getBlockParameter(String parameterName);
127: }
|