Web Resources

Web resources include javascripts and style sheets. They can be static and dynamic. Static resources are always added into page, but dynamic resources are added into page only when they are needed.

Static resources

Core resources such as AF.js and AF.css are static and always added to page.

Resource dependencies declared by modules are static. For example,


@ResourceDependencies({
	// META-INF/resources/cmobilecom/module/examplehr/employee.js
	@ResourceDependency(library="cmobilecom", 
			name="module/examplehr/employee.js")
})
public class WebExampleHRModule extends ExampleHRModule implements WebModule {

	...
}
If a module is included in an instance, all pages of the instance will have the module static resources added into page.

Dynamic resources

UI component resources and BeanViewEncoder resources are dynamic, and they are added to page only when they are rendered.

UI component example:

@ResourceDependencies({
	// META-INF/resources/cmobilecom/mycomponent.js
	@ResourceDependency(library="cmobilecom", name="mycomponent.js")
})
public class MyComponent extends UIInput {
	...
}
BeanViewEncoder resources are dynamic. For example,

public class MyBeanViewEncoder extends EntityBeanViewEncoder<MyType> {

	// define dynamic web resources
	@Override
	protected List<WebResource> getWidgetResources(String widgetType) {
		...
	}
	
}
See Bean View Encoder for detail.