01.02.02 Basic UI - Forge 02 - Sample Use Case - Basic UI 01 - Status
Sample Use Case - Basic UI 01 - Status
Let’s first create an enum for our state machine.
[simple-concise-forge]$ java-new-enum --named CatalogueStatus \
--targetPackage mx.rmm.simpleconcise.forge.model
***SUCCESS*** Enum mx.rmm.simpleconcise.forge.model.CatalogueStatus was created
[CatalogueStatus.java]$ java-new-enum-const \
--enumClass mx.rmm.simpleconcise.forge.model.CatalogueStatus \
--named DRAFT
[CatalogueStatus.java]$ java-new-enum-const \
--enumClass mx.rmm.simpleconcise.forge.model.CatalogueStatus \
--named PUBLISHED
[CatalogueStatus.java]$ java-new-enum-const \
--enumClass mx.rmm.simpleconcise.forge.model.CatalogueStatus \
--named HIDDEN
[CatalogueStatus.java]$ ls
DRAFT HIDDEN PUBLISHED
And add a new field to our existing entity Catalogue
[CatalogueStatus.java]$ cd ..
[model]$ cd Catalogue.java
[Catalogue.java]$ jpa-new-field --named status \
--type mx.rmm.simpleconcise.forge.model.CatalogueStatus \
--enumType STRING
***SUCCESS*** Field status created
[Catalogue.java]$ scaffold-generate \
--targets mx.rmm.simpleconcise.forge.model.Catalogue
***SUCCESS*** Scaffold was generated successfully.
Metrics
.java
541 total
.xhtml
361 total
.xml
173 total
Now our user interface looks a little diferent with a new search field and a new column on the table below.
On creation we are propted with a selection box for the enum values.
And everything is ok, right?
But there are problems with our UI, there are no restrictions to values set on fields
Fortunately this can be fixed in a clean way
[Catalogue.java]$ constraint-add --onProperty code --constraint NotNull
***SUCCESS*** Constraint NotNull successfully configured
[Catalogue.java]$ constraint-add --onProperty description \
--constraint NotNull
***SUCCESS*** Constraint NotNull successfully configured
[Catalogue.java]$ constraint-add --onProperty status --constraint NotNull
***SUCCESS*** Constraint NotNull successfully configured
[Catalogue.java]$ scaffold-generate \
--targets mx.rmm.simpleconcise.forge.model.Catalogue --overwrite
***SUCCESS*** Scaffold was generated successfully.
Metrics
.java
545 total
.xhtml
360 total
.xml
173 total
Our user interface now hints that there are required fields
And there are validations in place for said fields
But still we are missing how to transition in our statemachine within our busines case.
You can find source code You can find the source files here.
For now let’s continue with sample 02 of our basic UI requirements