Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified the doc for JBDS 8 Beta 2 with Forge 2 #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 15 additions & 27 deletions scripts/forge_html5_5_mins.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ Zero to HTML5 app
Prerequisites
-------------

* JBDS 7 setup
* JBDS 8 (Beta 2) setup
* JBoss EAP 6.x server available in JBDS
* Forge launched in JBDS *Cmd + 4*
* Switch to JBoss perspective

Once forge is started
---------------------
* `set ACCEPT_DEFAULTS true` in Forge to make it a bit less verbose
* Open the Forge Console

Create an app
-------------
Expand All @@ -20,24 +17,24 @@ This section of the script creates a new app from scratch from Forge, imports it

1. In the forge console, create a new Project

new-project --named rhsessions --topLevelPackage com.redhat.sessions
project-new --named rhsessions --topLevelPackage com.redhat.sessions

2. Now, we'll add some capabilities - Servlet, CDI, JPA, Bean Validation, JAX-RS

servlet setup; beans setup; persistence setup --provider HIBERNATE --container JBOSS_EAP6; validation setup --provider JAVA_EE; rest setup
servlet-setup; cdi-setup; jpa-setup --provider Hibernate --container JBOSS_EAP6; constraint-setup; rest-setup;

3. Now let's add some entities

entity --named Attendee
entity --named Session
jpa-new-entity --named Attendee
jpa-new-entity --named Session

4. Now, we want to add some Bean Validation constraints. You should end up with field definitions like these.


In `Session`:
+
[source,java]
---------------------------------------------------------------------------
----
@Size(message = "Must be > 20 and < 1000", min = 20, max = 1000)
private String description;

Expand All @@ -48,7 +45,7 @@ This section of the script creates a new app from scratch from Forge, imports it
@OneToMany
private Collection<Attendee> speakers = new ArrayList<Attendee>();

--------------------------------------------------------------------------
----
+
Now generate getters and setters.
+
Expand All @@ -57,30 +54,21 @@ Take a copy of the name field from Session, and paste into Attendee
In `Attendee`:
+
[source,java]
--------------------------------------------------------------------------
----
@NotNull
@Size(message = "Must be > 5 and < 50", min = 5, max = 50)
private String name;

--------------------------------------------------------------------------
----
+
Now generate getters and setters.
+
6. Scaffold endpoints for the entity.

cd ~~
rest endpoint-from-entity --contentType application/json com.redhat.sessions.model.*

7. Open up JAX-RS REST Web Services, and locate `GET /rest/session`. Right click on it, and choose *Run As -> Run On Server*. In the Web Service Tester, click the *Play* button, and show the result

Add HTML5 Mobile view
---------------------

1. Setup HTML5 scaffolding

scaffold-x setup --scaffoldType angularjs
Add HTML5 Mobile view with REST resources
-----------------------------------------

2. Generate the CRUD
1. Generate the RESTful CRUD with an AngularJS frontend and a JAX-RS backend.

scaffold-x from src/main/java/com/redhat/sessions/model/*
scaffold-generate --provider AngularJS --targets com.redhat.sessions.model.*

2. Open up JAX-RS REST Web Services, and locate `GET /rest/sessions`. Right click on it, and choose *Run As -> Run On Server*. In the Web Service Tester, click the *Play* button, and show the result