-
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 you 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 writes 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 {
...
}
###Options The ModelAnnotationProcessor supports these options
| Option | Description |
|---|---|
| `true` | Writes the Javascript in a pretty, readable format. *DEFAULT* |
| `false` | Writes the Javascript on one line (minified). |
| `extjs4` | Writes the model class in ExtJs4 format. *DEFAULT* |
| `touch2` | Writes the model class in Touch2 format. |
| `none` | Does not include any validation code. *DEFAULT* |
| `builtin` | Include validation code but only validations that are built into Ext JS and Sencha Touch. |
| `all` | Include all validation code. |
- Introduction
- Changelog 1.7.x
- Setup Maven
- Configuration
- Server Methods
- Model Generator
- Model Generator APT
- Development
- Links