No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
Server-Side Runtime Binding of Components
Server-side providers are more common, but if you don't need to access the server when you're creating a component, you can use a client-side provider instead.
Set the provider system attribute in the <aura:component> tag of an abstract component or interface to point to the server-side provider Java class.
The syntax of the provider system attribute is provider="java://package.class" where package.class is the fully qualified name for the class.
A Java provider must:
- Include the @Provider annotation above the class definition
- Implement either the ComponentDescriptorProvider or ComponentConfigProvider interface
At runtime, a provider has access to a shell of the abstract component or interface, including any attribute values that have been set. The model isn't constructed yet so you can't access it. The provide() method can examine the attribute values that are set on the component, and return a descriptor of the non-abstract component type that should be used.
ComponentDescriptorProvider
Use the ComponentDescriptorProvider interface to return a DefDescriptor describing the concrete component to use when you don’t need to set attributes for the component. For example:
1swfobject.registerObject("clippy.codeblock-0", "9");@Provider
2public class SampleDescProvider implements ComponentDescriptorProvider {
3
4 public DefDescriptor<ComponentDef> provide() {
5 DefDescriptor defDesc = null;
6
7 // logic to determine DefDescriptor to set and return.
8
9 return defDesc;
10 }
11}ComponentConfigProvider
Use the ComponentConfigProvider interface to return a ComponentConfig, which describes the concrete component to use in a DefDescriptor and enables you to set attributes for the component. For example:
1swfobject.registerObject("clippy.codeblock-1", "9");@Provider
2public class SampleConfigProvider implements ComponentConfigProvider {
3
4 public ComponentConfig<ComponentDef> provide() {
5 ComponentConfig cmpConfig = null;
6
7 // logic to determine DefDescriptor
8 // and attributes to set.
9
10 return cmpConfig;
11 }
12}Declaring Provider Dependencies
The Aura framework automatically tracks dependencies between definitions, such as components. However, if a component uses a provider that instantiates components that are not directly referenced elsewhere, use <aura:dependency> in the component to explicitly tell the framework about the dependency, which wouldn't otherwise be discovered by Aura.