Giter Club home page Giter Club logo

angularjs-scaffoldx-plugin's Introduction

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.

Prerequisites

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=<the location of the extracted distribution>

// or Windows
> set FORGE_HOME=<the location of the extracted distributio>

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, 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 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.

angularjs-scaffoldx-plugin's People

Contributors

vineetreynolds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.