About the Clara4Spring category

The add-on is an extension to the [Clara addon] (Vaadin Add-on Directory).
It adds autowiring support for nested components to it.

Dependencies

Clara4Spring depends on Clara (version > 1.4.0) and Spring framework, e.g

group, artifact, version
org.vaadin.addons, clara, > 1.4.0
org.springframework, spring-core
org.springframework, spring-context
org.springframework, spring-beans
org.slf4j, slf4j-api
com.vaadin, vaadin-server, > 1.7

The dependencies are not included in the distribution, intentionally, to provide you with most freedom to define the dependencies in your project with the versions of your choice.

Clara syntax for autowire

Sample of autowiring by bean id (with autowired bean id=‘specificTestComponent’):
<?xml version="1.0" encoding="utf-8"?>

<a:OtherTestComponent id=“testComponent”
xmlns:a=“urn:autowired:byId:specificTestComponent” />

Sample of autowiring by bean type (with autowired bean type = ‘org.vaadin.clara.spring.TestComponent’):
<?xml version="1.0" encoding="utf-8"?>

<a:TestComponent id=“testComponent”
xmlns:a=“urn:autowired:byType:org.vaadin.clara.spring”
/>

SpringClara

To allow Clara to autowire nested components it needs to be aware of the Spring application context. For this purpose the SpringClara class is introduced. SpringClara can be autowired itself when it is instantiated itself from a Spring container.

further info

For further details of usage see sample autowired declarative UIs in the unit tests @ Github