An open API service indexing awesome lists of open source software.

https://github.com/forge/angularjs-scaffoldx-plugin

The AngularJS scaffold-x plugin for Forge 1.x
https://github.com/forge/angularjs-scaffoldx-plugin

Last synced: 8 months ago
JSON representation

The AngularJS scaffold-x plugin for Forge 1.x

Awesome Lists containing this project

README

          

angularjs-scaffoldx-plugin
==========================

The AngularJS scaffold provider for the scaffold-x plugin in Forge 1.x. It creates AngularJS web-apps from JPA entities.

> If you're looking at using this in **Forge 2**, head over to [the Forge 2 AngularJS addon project](https://github.com/forge/angularjs-addon).

# Prerequisites

* [Forge 1.4.3](https://repository.jboss.org/nexus/service/local/repositories/releases/content/org/jboss/forge/forge-distribution/1.4.3.Final/forge-distribution-1.4.3.Final.zip)

# Install Forge

Copy the ZIP distribution to a directory and unzip it. This is your ```FORGE_HOME```:
```
// Linux or Mac OS X
$ export FORGE_HOME=

// or Windows
> set FORGE_HOME=
```

Modify the PATH to use this ```FORGE_HOME```:

```
// Linux or Mac OS X
$ export PATH=$FORGE_HOME/bin:$PATH

// or Windows
> set PATH=%FORGE_HOME%/bin:%PATH%
```

and start Forge:

```
$ forge
```

Or alternatively update your existing Forge installation to 1.4.3 - this may break due to [FORGE-849](https://issues.jboss.org/browse/FORGE-849), so it is would be better to download 1.4.3.

# Install the AngularJS scaffold-x provider plugin

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.

# Usage

A sample Forge script to try out the scaffold provider is listed below. It :
* creates a new project,
* sets up JPA and Bean Validation
* creates JPA entities
* creates fields in the JPA entities
* add Bean Validation constraints to the fields
* creates REST resources that expose the JPA entities via a REST API
* scaffolds an AngularJS app creating AngularJS views for every JPA entity

```
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/*";
```

> Note - the AngularJS scaffold plugin does not create REST resources out-of-the box.
>
> It works best with the root-and-nested-DTOs based REST resources generated by Forge.
>
> In the above script, the Forge `rest` command is used to create the REST resources.
> This will be changed in FORGE 2.x. You can track [FORGE-1402](https://issues.jboss.org/browse/FORGE-1402) for progress on this issue.

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.

# Deploy the generated scaffold to JBoss AS 7.x

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
```

# Responsive support

The generated scaffold relies on the responsive support provided by Bootstrap 3. It has been tested on Firefox 22 and Google Chrome 30 (both desktop and mobile versions). This may work on older browsers.

# Modifying the scaffolding templates

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.

# Issue Tracker

We do not use GitHub issues for issue tracking.
Please raise issues in the [JBoss JIRA Issue tracker](https://issues.jboss.org//secure/CreateIssueDetails!init.jspa?pid=12312020&components=12317568&issuetype=1&priority=3).