#Prerequisites
Copy the ZIP distribution to a directory and unzip it. This is your new FORGE_HOME:
$ export FORGE_HOME=<the location of the extracted build>
Modify the PATH to use this FORGE_HOME:
$ export PATH=$FORGE_HOME\bin:$PATH
and start Forge:
$ forge
Or alternatively update the existing Forge installation to 1.3.0 - this may break due to FORGE-849, so it is would be better to download 1.3.0.
Start Forge, and install the AngularJS scaffold-x provider plugin listed in the Forge central plugin repository.
$ forge install-plugin angularjs
The 'angularjs' scaffold provider should now be available in the list of scaffold-x providers:
$ list-scaffoldx-providers
* angularjs : AngularJS scaffolding
Note that this is not a provider for the older scaffold plugin.
A sample Forge script to try out the scaffold provider is as follows:
echo "Script to generate an AngularJS scaffold with uni-directional M:1 and 1:1 relationships";
set ACCEPT_DEFAULTS true;
new-project --named scaffold-example --topLevelPackage com.example.scaffoldexample;
persistence setup --provider HIBERNATE --container JBOSS_AS7;
validation setup --provider JAVA_EE;
entity --named Customer;
field string --named firstName;
constraint NotNull --onProperty firstName;
constraint Size --onProperty firstName --min 3 --max 100;
field temporal --type DATE --named dateOfBirth;
field boolean --named optForMail;
entity --named DiscountVoucher;
field string --named voucherCode;
entity --named StoreOrder;
field string --named product;
field int --named amount;
constraint Min --onProperty amount --min 1;
constraint Max --onProperty amount --max 50;
field string --named remarks;
constraint Size --onProperty remarks --max 100;
field manyToOne --named customer --fieldType com.example.scaffoldexample.model.Customer.java;
field oneToOne --named voucher --fieldType com.example.scaffoldexample.model.DiscountVoucher.java;
rest setup --activatorType WEB_XML;
rest endpoint-from-entity --contentType application/json com.example.scaffoldexample.model.*;
scaffold-x setup --scaffoldType angularjs;
cd ~~;
scaffold-x from "src/main/java/com/example/scaffoldexample/model/*";
You can save this (say, scaffold.fsh in the same working directory), and run it inside forge:
$ run scaffold.fsh
The default values are sufficient.
You may need to install the AS7 plugin. If you haven't done so already:
$ forge install-plugin jboss-as-7
And then setup the AS7 plugin in the project:
$ as7 setup
Now, you can build the project
$ build
and start and deploy to as7
$ as7 start
$ as7 deploy
The generated scaffold relies on the responsive support provided by Twitter Bootstrap. It has been tested on Firefox 20 and Google Chrome 26 (both desktop and mobile versions). This may work on older browsers.
The scaffold-x plugin allows developers to modify the templates used by the scaffold providers (as long as the providers utilize a template driven approach). This feature is meant for developers who wish to control aspects of the scaffold provider, without writing another provider.
Freemarker templates used by the AngularJS scaffolding provider, can be installed during project setup as:
$ scaffold-x setup --scaffoldType angularjs --installTemplates
The templates are now available in src/main/templates and can be modified to modify the generated scaffold in certain areas. The scaffolding plugin will use the templates from this location, over the factory-shipped ones.
Bi-directional relationships across JPA entities will not work. The generated REST resources cannot handle bi-directional associations yet. FORGE-606 is the issue to track.