Coder Social home page Coder Social logo

errai-tutorial's Introduction

Errai Getting Started Demo

This simple demo allows users to create contact entires for an address book. The user interface is designed using plain HTML5 and CSS. Errai UI enables the injection of UI fields into client-side Java classes as well as adding dynamic behaviour to these fields (such as event handlers). The demo also makes use of Errai's two-way data binding and page navigation modules. This can all be seen in ContactListPage.java (the markup for which can be found in contact-page.html).

Creating contacts is done using a simple JAX-RS endpoint and Errai's typesafe REST caller support (see the @EventHandler method for the submit button in ContactListPage.java). Every time a new contact is created, the server will fire a CDI event which will be observed by all connected clients (new contacts will automatically appear in the displayed contact lists of all connected clients). The relevant code for firing and observing this CDI event can be found in ContactStorageServiceImpl.java and ContactListPage.java. The filed contacts are persisted on the server.

This demo is designed to work with a full Java EE 7 server such as Wildfly 8. Although it should be possible to craft a deployment of this demo to a simpler web server, it's much simpler to deploy to an EE 7 capable app server.

Prerequisites

  • Maven 3 (run mvn --version on the command line to check)
  • An unzipped copy of Wildfly 8 (Optional)

More detailed instructions can be found in our Setup Tutorial

Build and deploy (production mode)

To build a .war file and deploy it to the local running Wildfly instance:

% mvn clean package wildfly:deploy

Once the above command has completed, you should be able to access the app at the following URL:

http://localhost:8080/errai-tutorial

More detailed instructions can be found here

Code and Refresh (development mode)

Using GWT's Super Dev Mode, it is possible to instantly view changes to client-side code by simply refreshing the browser window.

http://localhost:8080/errai-crud

Code and Refresh (development mode)

Using GWT's Super Dev Mode, it is possible to instantly view changes to client-side code simply by refreshing the browser window.

If you're using the Google Plugin for Eclipse or IntelliJ Ultimate Edition follow these instructions to start development mode.

Alternatively, you should be able to start the demo in development mode with this single command:

% mvn clean gwt:run

When the GWT Dev Mode window opens, press "Launch Default Browser" to start the app. You can now debug client-side code directly in the browser using source maps (make sure source maps are enabled in your browser). Alternatively, you can also configure a debug environment for Eclipse by installing

To debug server-side code, set up a remote debugger on port 8001. Then:

  • Run mvn clean gwt:debug
  • Start your remote debugger
  • Press "Launch Default Browser"

See our development guide here for more instructions on setting up dev mode and other details.

Build and deploy as native app to your mobile device

The native application will have to know the absolute path to your server or cluster. For this demo you will have to change the REST and Errai Bus endpoint URL in Config.java and App.java (see comments) before building the native application.

To produce the native applications run:

% mvn clean package -Pmobile,jboss7 -Dplatform=android

After that you can simply install the native app on your phone or tablet.

e.g for Android run:

% adb install target/template/platforms/android/bin/HelloCordova-debug.apk

Troubleshooting

Here are some resources that may help if you encounter difficulties:

errai-tutorial's People

Contributors

csadilek avatar ddadlani avatar edewit avatar jfuerth avatar lincolnthree avatar mbarkley avatar paulovmr avatar

Watchers

 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.