-
Notifications
You must be signed in to change notification settings - Fork 64
ModelGeneratorAPT
Since 1.3.1
ExtDirectSpring contains an APT Processor that is build upon the ModelGenerator. This processor creates Javascript model files during compile time.
In a Maven project add the following configuration into the pom.xml. The apt-maven-plugin runs by default during the generate-resources phase.
Calling maven with mvn generate-resources
on the command line will trigger this phase and creates the source code files if not already created.
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.0.8</version>
<executions>
<execution>
<id>modelgen</id>
<goals>
<goal>process</goal>
</goals>
<configuration>
<processor>ch.ralscha.extdirectspring.generator.ModelAnnotationProcessor</processor>
<outputDirectory>src/main/webapp/app</outputDirectory>
<options>
<!-- Add options here. See description below -->
</options>
</configuration>
</execution>
</executions>
</plugin>
The ModelAnnotationProcessor creates one Javascript file for every Java class that is annotated with @Model in the outputDirectory.
Example
When the @Model annotation does not contain a value attribute the processor creates the Javascript file directly in the outputDirectory and uses the class name as file name. src/main/webapp/app/Club.js
@Entity
@Model
public class Club extends AbstractPersistable {
...
}
When a value attribute exists the processor creates the file and subdirectories based on this value. The processor ignores the first part of the string (MyApp), names the file with the last part (Team) and creates subdirectories with all the parts between (model). src/main/webapp/app/model/Team.js
@Entity
@Model(value = "MyApp.model.Team")
public class Club extends AbstractPersistable {
...
}
src/main/webapp/app/model/part/Team.js
@Entity
@Model(value = "MyApp.model.part.Team")
public class Club extends AbstractPersistable {
...
}
The ModelAnnotationProcessor supports these options
Option | Description |
---|---|
<debug>true</debug> |
Writes the Javascript in a pretty, readable format. DEFAULT |
<debug>false</debug> |
Writes the Javascript on one line. |
<outputFormat>extjs4</outputFormat> |
Writes the model class in ExtJs4 format. DEFAULT |
<outputFormat>touch2</outputFormat> |
Writes the model class in Touch2 format. |
<includeValidation>none</includeValidation> |
Does not include any validation code. DEFAULT |
<includeValidation>builtin</includeValidation> |
Includes validation code but only validations that are built into Ext JS and Sencha Touch. |
<includeValidation>all</includeValidation> |
Includes all validation code. |
<createBaseAndSubclass>true</createBaseAndSubclass> (since 1.3.2)
|
Creates two files (base and subclass). It does not overwrite the subclass file if it exists.
Example
/* ModelBase.js */ Ext.define('MyApp.model.ModelBase', { extend: 'Ext.data.Model', fields: [ ... ] }); |
<useSingleQuotes>true</useSingleQuotes> (since 1.3.2)
|
Writes single quotes instead of double quotes (default) |
<surroundApiWithQuotes>true</surroundApiWithQuotes> (since 1.3.2)
|
Surrounds the values of the proxy/api object with quotes
proxy : { type : "direct", api : { read : "userService.read", destroy : "userService.destroy" } } |
- Introduction
- Changelog 1.7.x
- Setup Maven
- Configuration
- Server Methods
- Model Generator
- Model Generator APT
- Development
- Links