- This topic has 1 reply, 2 voices, and was last updated 13 years, 9 months ago by jkennedy.
-
AuthorPosts
-
rdennisjMemberI created a customization template, and on reviewing the MasterDetail.jet template, I’m having difficulty interpreting some of the tags:
/**
* A Master/Detail style UI that presents a list of <sw:javaType select=”$model” alias=”gwtdatatype” package=”false”/>s with a “New” button to create new records as well as a Tab area
* to allow multiple records to be edited at the same time. Also provides the ability to delete records.
<sw:generated />
*/
public class <sw:javaType select=”$model” alias=”gwtmasterdetail” package=”false”/> implements <java:import><sw:javaType select=”$model/project” alias=”gwtcrudsection” package=”true”/></java:import> {Questions:
1. The first line references: alias=”gwtdatatype”. How is this used? The javadoc says the alias property is ‘an optional alias that identifies which artifact definition to use’ but I don’t see any references to it in any of the .springDSL artifacts.
2. Likewise for the aliases for ‘gwtmasterdetail’ and ‘gwtcrudsection’
3. The last line above references: select=”$model/project”. I can see how $model retrieves a reference to the model’s core name, but how is the ‘project’ part of it used?Thanks again
jkennedyMemberGreat questions,
In our underlying architecture, each File that is generated is considered to be an “Artifact” and each “Artifact” has a definition that specifies its type (like Java, XML, Properties, etc) as well as its file location, etc. These artifact Definitions are keyed by an alias and are defined within our plugins and tooling. Each Java Artifact has a .jet template that is used to generate that file.The alias is used to reference the Java class name for other Java files that are being generated from the same instance of the Model. In the example above, when we request the <sw:javaType and pass in the “gwtdatatype” alias, we are asking the generation engine to resolve the Java class name (and optionally the package) of another Java file that is being generated from this same instance of the data model. For the GWT layer, we almost always match the name of the Alias to the name of the Jet template so you can look for a Jet template called GWTDataType.jet to see the code file that we are actually referring too.
Some files that we generate are generated on a “per data type” basis, and some are generated on a “per project” basis. In the case of <sw:javaType select=”$model/project” alias=”gwtcrudsection” package=”true”/> we are saying (emit the Java class name for the Artifact “CrudSection” that is being generated at the Project level for this data type)
You can look at the CrudSection.jet file to see the code that is being generated under this alias.
By using this approach, it gives the .jet template developer the option to reference any other generated Java file using a key (or alias) rather than trying to hard code file names and locations and lets the generation engine dynamically derive the file names and package locations for generated files without breaking existing templates.
Hope this helps and thanks again,
Jack -
AuthorPosts