Skip to content
ralscha edited this page Feb 22, 2013 · 10 revisions

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 {
  ...
}

###Options 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.
Clone this wiki locally