<?xml version="1.0" encoding="UTF-8"?>
<!--
    JBoss, Home of Professional Open Source
    Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual
    contributors by the @authors tag. See the copyright.txt in the
    distribution for a full listing of individual contributors.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<cheatsheet title="HTML5 + Mobile + JAX-RS: Kitchensink quickstart">
  <intro>
    <description>
      This quickstart shows off HTML5 based desktop/mobile web application development with Java EE 7 on Red Hat JBoss Enterprise Application Platform 7 or later. This project uses HTML5, jQuery Mobile, JAX-RS 2.0, CDI 1.2, EJB 3.2, JPA 2.1 and Bean Validation 1.1. It includes a persistence unit and some sample persistence and transaction code to help you get your feet wet with database access in enterprise Java.
      <br/><br/>
      <b>HTML5</b>
      <br/><br/>
      HTML5 refers to both the newest version of HTML language, and the set of associated technologies that allow creation of web applications and sites that target various devices.
      <br/><br/>
      <b>jQuery Mobile</b>
      <br/><br/>
      jQuery Mobile is a client-side web framework with touch-friendly widgets. It provides a HTML5-based user-interface that uses semantic markup. Sites built with jQuery Mobile are accessible on all popular smartphone, tablet and desktop devices.
      <br/><br/>
      <b>JAX-RS: The Java API for RESTful Web Services</b>
      <br/><br/>
      JAX-RS is a specification in Java EE that allows application developers to easily expose Java services as RESTful web services.
      <br/><br/>
      <b>EJB 3.2</b>
      <br/><br/>
      EJB 3.2 is an update to the EJB specification for Java EE 7. It allows application developers to build business components and services.
      <br/><br/>
      <b>JPA 2.1</b>
      <br/><br/>
      JPA 2.1 is an update to the JPA specification for Java EE 7. It provides application developers with an object-relational mapping facility to manage relational data.
      <br/><br/>
      <b>Bean Validation 1.1</b>
      <br/><br/>
      Bean Validation 1.1 is an update to the JPA specification for Java EE 7. It was inspired by Hibernate Validator. It allows application developers to specify constraints once (often in their domain model), and have them applied in all layers of the application, protecting data and giving useful feedback to users.
      <br/><br/>
    </description>
  </intro>
  <item
    skip="false"
    title="The kitchensink-html5-mobile example in depth">
    <description>
      The kitchensink-html5-mobile application shows off a number of Java EE technologies such as HTML5, jQuery Mobile, JAX-RS 2.0, CDI 1.1, EJB 3.2, JPA 2.1 and Bean Validation 1.1.
      It does this by providing a member registration database, available via HTML5 and JAX-RS.
      <br/><br/>
      As usual, let&apos;s start by looking at the necessary deployment descriptors. By now, we&apos;re very used to seeing <b>beans.xml</b> in <b>WEB-INF/</b> (which can be found in the <b>src/main/webapp</b> directory of the example). Notice that, once again, we don&apos;t need a web.xml. There are two configuration files (which can be found in the <b>src/main/resources</b> directory of the example) — <b>WEB-INF/classes/META-INF/persistence.xml</b>, which sets up JPA, and <b>WEB-INF/classes/import.sql</b> which Hibernate, the JPA provider in Red Hat JBoss Enterprise Application Platform, will use to load the initial users into the application when the application starts. We discussed both of these files in detail in The <b>greeter example in depth</b>, and these are largely the same.
    </description>
    <command
    required="true"
    returns="currentProject"
    serialization="org.jboss.tools.project.examples.cheatsheet.getProjectForCheatsheet"/>
  </item>

  <item
    skip="true"
    title="jQuery Mobile pages in index.html">
    <description>
    Next, let&apos;s take a look the <b>index.html</b> file that displays the page the user sees. The HTML page consists of several jQuery Mobile pages.
    </description>
    <subitem
          label="jQuery Mobile and other required JavaScript and CSS artifacts are added to the page in the head element."
          skip="true">
       <command
             required="false"
             serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=24,toLine=60,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="When you perform the previous action, the page is now open in the Visual Page Editor. The Visual Page Editor provides a live-editing experience - it allows you to make changes to the source of the HTML page and view the results in an embedded browser, all within Eclipse."
          skip="true">
    </subitem>
    <subitem
          label="You can add jQuery Mobile components to the page via the Palette. When the &quot;index.html&quot; file is open in the &quot;Visual Page Editor&quot;, the palette will offer jQuery Mobile components that can be added to the page. To view the palette, perform the current action. The palette will be opened in a new tab in your workspace."
          skip="true">
       <command
             required="false"
             serialization="org.eclipse.ui.views.showView(org.eclipse.ui.views.showView.viewId=org.eclipse.gef.ui.palette_view)"/>
    </subitem>
    <subitem
          label="You could even open the palette manually. Click the &quot;Window&quot; entry in the menu bar. Select the &quot;Show View&quot; entry in it, and then choose the &quot;Other...&quot; entry. This opens a dialog displaying several other views that can be opened. Select the &quot;Palette&quot; item located under the &quot;General&quot; section; doing so will open the &quot;Palette&quot;."
          skip="true">
    </subitem>
    <subitem
          label="The first jQuery Mobile page is the introduction page."
          skip="true">
      <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=140,toLine=189,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="A jQuery Mobile page can be added to HTML page by clicking the page component in the palette. This adds a new jQuery Mobile page at the current cursor location in the editor. You can also drag and drop the page component from the palette to the HTML page."
          skip="true">
    </subitem>
    <subitem
          label="We have a header that displays a button to view information about the application. Clicking the button opens a jQuery Mobile page as a dialog, displaying information about the application."
          skip="true">
      <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=142,toLine=145,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="Note that headers can be added to pages by clicking the Header Bar component in the palette."
          skip="true">
    </subitem>
    <subitem
          label="The content section contains text introducing the application features."
          skip="true">
      <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=148,toLine=165,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="And we have a footer containing a navigation bar to navigate to the Home page (the current page), and the Add member and List member pages."
          skip="true">
        <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=272,toLine=280,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="Note that footers can be added to pages by clicking the Footer Bar component in the palette."
          skip="true">
    </subitem>
    <subitem
          label="The page also contains an embedded dialog that displays information about the application. It was introduced earlier as the dialog displayed when clicking the button in the header section. Dialogs can be added to the jQuery Mobile page through the Dialog widget in the palette."
          skip="true">
          <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=168,toLine=188,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="The next jQuery Mobile page is the one that allows you to create a new member. The header and footer is similar to the one in the introduction page."
          skip="true">
          <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=192,toLine=226,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="The content section allows us to register new members via a registration form (with id &quot;reg&quot;). There should be one member already created when the application starts. The form in the content section allows input of the name, email and telephone number of a member."
          skip="true">
          <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=192,toLine=226,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="Forms can be added to pages by clicking the Form component in the jQuery Mobile palette. The rest of the form can be constructed using other form components available in the palette."
          skip="true">
    </subitem>
    <subitem
          label="The name is input via a HTML form text field. Such a field can be added with the text input component."
          skip="true">
          <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=205,toLine=208,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="The member&apos;s email is input through a HTML5 form input field of type &apos;email&apos;. Browsers supporting this form of input will perform validation of the email keyed in by the user. Like the name field, the email field can also be added through the jQuery Mobile palette via the text input component. The displayed dialog will allow you to specify that the type should be an email field, among other parameters."
          skip="true">
          <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=209,toLine=212,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="The telephone number is input through a HTML form field of type &apos;telephone number&apos; with a pattern allowing numbers of length 10 through 12. Browsers supporting the telephone number as input may display an reduced keyboard (mobile browsers typically display such a keyboard). Browsers supporting &apos;telephone number&apos; input will also perform validation of the number keyed in by the user. And like the email field, the palette can be used to construct this field."
          skip="true">
          <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=213,toLine=216,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="The next jQuery Mobile page is the one to display members. The header and footer is similar to the one in the introduction page."
          skip="true">
          <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=229,toLine=269,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="The content section allows us to refresh the list of members displayed. The members are displayed in a placeholder div element with id: &quot;members&quot;."
          skip="true">
          <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=236,toLine=268,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
  </item>

  <item
    skip="true"
    title="Presentation logic in index.html">
    <description>
    Next, let&apos;s take a look at the wiring done in JavaScript, defined in the <b>index.html</b> file.
    </description>
    <subitem
          label="Event handlers are attached to handle various events."
          skip="true">
      <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=63,toLine=118,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="On entering the member list page, the table displaying all members is updated via an event handler for the &apos;pagebeforeshow&apos; event."
          skip="true">
      <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=85,toLine=88,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="When the submit button in the registration page is clicked, the registered event handler serializes the data in the form and delegates the registration process to another function."
          skip="true">
      <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=91,toLine=97,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="When the cancel button in the registration page is clicked, the registered event handler ensures that the form fields are cleared and any messages are removed from the view."
          skip="true">
      <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=100,toLine=107,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="When the refresh button in the member list page is clicked, the registered event handler delegates the work of updating the table to another function."
          skip="true">
      <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=109,toLine=111,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="On entering the registration page, any messages displayed in the registration form are cleared, This is similar to the registered event handler for the cancel button on the same page."
          skip="true">
      <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=113,toLine=117,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
    <subitem
          label="We also define a very simple jQuery plugin that can be invoked on a jQuery object representing a form. This plugin converts the registration form values into a JavaScript object that can be easily passed to the server as a JSON object."
          skip="true">
        <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,fromLine=120,toLine=134,editorID=org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor)"/>
    </subitem>
  </item>

  <item
    skip="true"
    title="app.js">
    <description>
    We now take a look at the core JavaScript functionality for the application referenced from JavaScript methods that were earlier defined in the <b>index.html</b> file.
    This is defined in the <b>app.js</b> file present in the <b>src/main/webapp/js/app.js</b> file of the project.
    The core functionality invokes the REST API on the server to register new members. It also updates the member list when the refresh button is clicked.
    </description>
    <subitem
          label="In the &quot;buildMemberRows&quot; function, we apply the Underscore.js template present in the element with id &quot;member-tmpl&quot; using the array of members as an argument to the template."
          skip="true">
      <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/js/app.js,fromLine=23,toLine=25)"/>
    </subitem>
    <subitem
          label="In the &quot;updateMemberTable&quot; function, we invoke the REST API located at &quot;/rest/members&quot; to obtain the collection of members. Once the collection is available in the response, we update the contents of the &quot;members&quot; element with the output of the &quot;buildMemberRows&quot; function."
          skip="true">
      <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/js/app.js,fromLine=28,toLine=47)"/>
    </subitem>
    <subitem
          label="The &quot;registerMember&quot; function invokes the REST API located at &quot;/rest/members&quot; with the JSON representation of the values in the registration form. Any existing error messages are removed."
          skip="true">
      <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/js/app.js,fromLine=54,toLine=98)"/>
    </subitem>
    <subitem
          label="On successful registration, the form values are cleared, a message indicating successful registration is displayed and the list of members is updated."
          skip="true">
      <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/js/app.js,fromLine=68,toLine=78)"/>
    </subitem>
    <subitem
          label="On a failure to register, if the HTTP response code is 400 or 409, the response is parsed and any error messages are displayed adjacent the form input fields."
          skip="true">
        <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/js/app.js,fromLine=79,toLine=92)"/>
    </subitem>
  </item>

  <item
        skip="true"
        title="Setup LiveReload">
     <description>
      LiveReload is an open source tool that refreshes web pages open in browsers as their source is edited. Immediate and automatic web page refreshing, without the need to manually refresh, simplifies the workflow of web developers. JBoss Developer Studio provides tooling that implements LiveReload in the IDE.
      <br/><br/>
       Open the Servers view, right-click in it, select &quot;New&quot; and choose to create a new <b>Server</b>.
       Select &quot;LiveReload Server&quot;, located in the &quot;Basic&quot; section, as the new server to create. Click Finish to create a new server.
    </description>
  </item>

  <item
        skip="true"
        title="Using LiveReload">
     <description>
       We shall now explore the use of LiveReload to optimise our web development workflow.
    </description>
    <subitem
          label="Once again in the Servers view, select the LiveReload Server created in the previous step, and start it."
          skip="true">
    </subitem>
    <subitem
          label="Right-click the &quot;index.html&quot; file, select the &quot;Open With&quot; entry, and choose the &quot;Web Browser via LiveReload Server&quot; option. If you're starting LiveReload for the first time, you will be prompted with a dialog. You will be asked whether you want to &quot;Inject the livereload.js script in HTML pages&quot; and to &quot;Allow Remote connections&quot;. The defaults are sufficient - click Yes to proceed. If you do not choose to inject the livereload.js script, you must use a LiveReload extension with your browser."
          skip="true">
          <!-- Disable this command for now. We cannot open the same file in two different editors.
          <command
        required="false"
        serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/webapp/index.html,editorID=org.jboss.tools.livereload.openFileInBrowserWithLiveReload)"/>
        -->
    </subitem>
    <subitem
          label="You can make changes to the &quot;index.html&quot; page without refreshing it in the browser. All you need to do is save your changes, and the LiveReload tooling will ensure that the browser is updated. Note that we haven't written a backend service yet, so the page in the web browser will only display changes to the static content. It will not display any members, nor will it allow new members to be added. We will get LiveReload to work in the context of a running application with backend services, at a later stage in the tutorial."
          skip="true">
    </subitem>
  </item>

  <item
        skip="true"
        title="Member.java">
     <description>
       Next, let&apos;s take a look at the Member entity, before we look at how the application is wired together with the backend:
    </description>
    <subitem
            label="As usual with JPA, we define that the class is an entity by adding @Entity"
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/model/Member.java,fromLine=36)"/>
  </subitem>
  <subitem
            label="Members are exposed as a RESTful service using JAX-RS. We can use JAXB to map the object to XML and to do this we need to add @XmlRootElement."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/model/Member.java,fromLine=37)"/>
  </subitem>
  <subitem
            label="Bean Validation allows constraints to be defined once (on the entity) and applied everywhere. Here we constrain the person's name to a certain size and regular expression. "
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/model/Member.java,fromLine=47,toLine=49)"/>
  </subitem>
  <subitem
            label="Hibernate Validator also offers some extra validations such as @Email. "
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/model/Member.java,fromLine=54,toLine=54)"/>
  </subitem>
  <subitem
            label="@Digits, @NotNull and @Size are further examples of constraints. "
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/model/Member.java,fromLine=57,toLine=59)"/>
  </subitem>

  </item>

  <item
        skip="true"
        title="MemberRepository.java">
     <description>
       Let&apos;s take a look at MemberRepository, which is responsible for interactions with the persistence layer:
    </description>
    <subitem
            label="The bean is application scoped, as it is a singleton."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/data/MemberRepository.java,fromLine=29)"/>
  </subitem>
  <subitem
            label="The entity manager is injected, to allow interaction with JPA."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/data/MemberRepository.java,fromLine=32,toLine=33)"/>
  </subitem>
  <subitem
            label="The JPA criteria api is used to load a member by his or her unique identifier, email address."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/data/MemberRepository.java,fromLine=39,toLine=48)"/>
  </subitem>
  <subitem
            label="The criteria api can also be used to load lists of entities ."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/data/MemberRepository.java,fromLine=50,toLine=59)"/>
  </subitem>

  </item>

  <item
        skip="true"
        title="MemberRegistration.java">
     <description>
       Let&apos;s now look at MemberRegistration, the class that allows us to create new members from the server-side REST service.
    </description>
    <subitem
            label="This bean requires transactions as it needs to write to the database. Making this an EJB gives us access to declarative transactions - much simpler than manual transaction control! "
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/service/MemberRegistration.java,fromLine=28)"/>
  </subitem>
  <subitem
            label="Here we inject a JDK logger, defined in the Resources class."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/service/MemberRegistration.java,fromLine=31,toLine=32)"/>
  </subitem>
  <subitem
            label="An event is sent every time a member is updated. This allows other pieces of code (in this quickstart the member list is refreshed) to react to changes in the member list without any coupling to this class. "
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/service/MemberRegistration.java,fromLine=43)"/>
  </subitem>

  </item>

  <item
        skip="true"
        title="MemberService.java">
     <description>
       Let&apos;s now look at MemberService, the class that is responsible for exposing the RESTful service.
    </description>
    <subitem
            label="The RESTful service is accessible at the &quot;/members&quot; URI relative to the base URI of the server."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/rest/MemberService.java,fromLine=51)"/>
  </subitem>
  <subitem
            label="Again, we inject a JDK logger, defined in the Resources class."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/rest/MemberService.java,fromLine=54,toLine=55)"/>
  </subitem>
  <subitem
            label="We inject a JSR-303 Validator to use it for validating the JPA entity attributes before passing it down to other classes."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/rest/MemberService.java,fromLine=57,toLine=58)"/>
  </subitem>
  <subitem
            label="We also inject instances of MemberRepository and MemberRegistration to act as delegates in this RESTful service."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/rest/MemberService.java,fromLine=60,toLine=64)"/>
  </subitem>
  <subitem
            label="The listAllMembers method processes all HTTP GET requests to the &quot;/members&quot; URI, providing a list of all Member instances, in a JSON response."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/rest/MemberService.java,fromLine=66,toLine=70)"/>
  </subitem>
  <subitem
            label="The lookupMemberById method processes HTTP GET requests to a URI with path template &quot;/members/{id}&quot;. It provides a single Member instance (whose id matches the provided id in the URI), as response of type JSON."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/rest/MemberService.java,fromLine=72,toLine=81)"/>
  </subitem>
  <subitem
            label="The createMember method processes all HTTP POST requests to the &quot;/members&quot; URI. It consumes a POST request with a body containing a JSON object representing a Member instance. The JAX-RS provider de-serializes the POST body into a Member. It validates the provided Member, registers it if the Member is valid, and creates a HTTP response, It provides the newly registered Member instance as a JSON object, in the response."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/rest/MemberService.java,fromLine=87,toLine=118)"/>
  </subitem>
  <subitem
            label="The validateMember method is a private method whose responsibility is to validate the provided Member instance for violations of the declared constraints, and also to verify if the supplied email of a Member is unique. It uses the JSR-303 validator instance to validate the Member. Any constraint violations reported by the validator are rethrown as a ConstraintViolationException."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/rest/MemberService.java,fromLine=134,toLine=146)"/>
  </subitem>
  <subitem
            label="The createViolationResponse is used to construct a meaningful HTTP response when violations of declared constraints are found by the JSR-303 validator. Every violation is serialized with the name of the attribute that failed violation, and a message describing the violation."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/rest/MemberService.java,fromLine=155,toLine=165)"/>
  </subitem>
  <subitem
            label="The emailAlreadyExists method verifies for uniqueness of the email address in the supplied Member. It uses the MemberRepository to determine if an existing member with the same email can be found."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/rest/MemberService.java,fromLine=174,toLine=182)"/>
  </subitem>

  </item>

  <item
        skip="true"
        title="Resources.java">
     <description>
       Now, let's take a look at the Resources class, which provides resources such as the entity manager. CDI recommends using "resource producers", as we do in this example, to alias resources to CDI beans, allowing for a consistent style throughout our application:
    </description>
    <subitem
            label="We use the 'resource producer' pattern, from CDI, to 'alias' the old fashioned @PersistenceContext injection of the entity manager to a CDI style injection. This allows us to use a consistent injection style (@Inject) throughout the application. "
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/util/Resources.java,fromLine=40,toLine=42)"/>
  </subitem>
  <subitem
            label="We expose a JDK logger for injection. In order to save a bit more boiler plate, we automatically set the logger category as the class name! "
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/main/java/org/jboss/as/quickstarts/html5_mobile/util/Resources.java,fromLine=44,toLine=47)"/>
  </subitem>
  <subitem
            label="If you want to define your own datasource, take a look at the Configuration Guide for Red Hat JBoss Enterprise Application Platform"
            skip="true">
    <command
           required="false"
           serialization="org.eclipse.ui.browser.openBrowser(url=https://access.redhat.com/documentation/en/red-hat-jboss-enterprise-application-platform/)"/>
  </subitem>
  </item>

  <item
        skip="true"
        title="Run and deploy the application">
     <description>
       Before you proceed, ensure that you have setup and configured a JBoss EAP 7 server.
       <br/><br/>
       Right-click the project and select <b>Run As</b> &gt; <b>Run On Server</b>. <!-- or click on the &quot;Click to Perform&quot; link below -->
    </description>
    <!-- the runOnServer command is not implemented yet
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.actions.runOnServer(project=${currentProject})"/>
  -->
  <action
    pluginId="org.jboss.tools.project.examples.cheatsheet"
    class="org.jboss.tools.project.examples.cheatsheet.actions.RunOnServer"
    param1="${currentProject}"/>
  </item>
  <item
        skip="true"
        title="Open the application in BrowserSim">
     <description>
       Locate the &quot;Run BrowserSim&quot; button on the toolbar and click it, or click on the &quot;Click to Perform&quot; link below.
       This launches BrowserSim where you can simulate the execution of the application on a mobile browser.
       Once you launch BrowserSim, navigate to the deployed application via the BrowserSim address bar. The application is usually accessible at this following link: <b>http://localhost:8080/jboss-kitchensink-html5-mobile/</b>
    </description>
     <command
           required="false"
           serialization="org.jboss.tools.vpe.browsersim.eclipse.commands.runBrowserSim"/>
  </item>
  <item
        skip="true"
        title="Using LiveReload with the deployed application">
     <description>
       Once again in the Servers view, select the &quot;jboss-kitchensink-html5-mobile&quot; deployment under the JBoss EAP 7 Runtime Server, and right-click on it.
       Select the &quot;Show In&quot; entry in the menu, and open the deployed resource in a <b>Web Browser via LiveReload Server</b>. This launches the application in a web browser with the LiveReload scripts injected into it.
       You can proceed to make changes to the <b>index.html</b> and it would immediately reflect in the opened Web Browser on saving the changes.
       <br/><br/>
       As is the case with LiveReload tooling, there is no need to refresh the web browser after you save the changes in the editor. At the same time, opening the application in this manner will allow the client-side JavaScript in <b>app.js</b> to access the <b>MemberResource</b> REST API on the server-side. You can make changes to the page without refreshing them while continuing to use the backend services deployed on JBoss EAP 7.
       <br/><br/>
       <b>Note:</b> In the earlier section in the tutorial, where the <b>index.html</b> file was opened via the LiveReload Server, the file was not deployed in an application running on a JBoss EAP 7 server. Hence, it could not access the backend - and member details could not displayed and new members could not be added. We have just demonstrated how to overcome that problem.
    </description>
  </item>
  <item
        skip="true"
        title="Arquillian">
     <description>
       If you&apos;ve been following along with the Test Driven Development craze of the past few years,
       you&apos;re probably getting a bit nervous by now, wondering how on earth you are going to test your application.
       Lucky for you, the Arquillian project is here to help!
    <br/><br/>
    Arquillian provides all the boiler plate for running your test inside Red Hat JBoss Enterprise Application Platform 7,
    allowing you to concentrate on testing your application.
    In order to do that, it utilizes Shrinkwrap, a fluent API for defining packaging,
    to create an archive to deploy.
    We'll go through the testcase, and how you configure Arquillian in just a moment,
    but first let's run the test.

    </description>
  </item>
  <item
        skip="true"
        title="Start Arquillian tests">
    <description>
      Arquillian defines two modes, managed and remote.
      The managed mode will take care of starting and stopping the server for you,
      while the remote mode connects to an already running server.
      <br/><br/>
      The following action starts the test in the <b>remote</b> mode because you have started the server in the previous step.
    <br/>
        Right-click the project, select <b>Properties&gt;Maven</b> and
        enter <b>arq-remote</b> to the <b>Active Maven Profile</b> field.
        After that, right-click the project and select <b>Run As&gt;JUnit test</b>.
        <br/><br/>
        After performing this action, you should see a green bar in the <b>JUnit</b> view!
        All three tests should have completed successfully.
    </description>
    <!-- the launchJUnitTest command is not implemented yey
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.actions.launchJUnitTest(project=${currentProject}, activateProfile=arq-remote)"/>
  -->

  <action
      pluginId="org.jboss.tools.project.examples.cheatsheet"
      class="org.jboss.tools.project.examples.cheatsheet.actions.LaunchJUnitTest"
      param1="${currentProject}"
        param2="arq-remote"/>
  </item>

  <item
        skip="true"
        title="MemberRegistrationTest.java">
    <description>
      So far so good, the test is running. But what does the test look like?
    </description>
    <subitem
            label="@RunWith(Arquillian.class) tells JUnit to hand control over to Arquillian when executing tests."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/test/java/org/jboss/as/quickstarts/html5_mobile/test/MemberRegistrationTest.java,fromLine=49)"/>
  </subitem>
  <subitem
            label="The @Deployment annotation identifies the createTestArchive static method to Arquillian as the one to use to determine which resources and classes to deploy "
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/test/java/org/jboss/as/quickstarts/html5_mobile/test/MemberRegistrationTest.java,fromLine=51)"/>
  </subitem>
  <subitem
            label="We add just the classes needed for the test, nothing more "
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/test/java/org/jboss/as/quickstarts/html5_mobile/test/MemberRegistrationTest.java,fromLine=55,toLine=56)"/>
  </subitem>
  <subitem
            label="We also add persistence.xml as our test is going to use the database "
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/test/java/org/jboss/as/quickstarts/html5_mobile/test/MemberRegistrationTest.java,fromLine=57)"/>
  </subitem>
  <subitem
            label="Of course, we must add beans.xml to enable CDI."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/test/java/org/jboss/as/quickstarts/html5_mobile/test/MemberRegistrationTest.java,fromLine=58)"/>
  </subitem>
  <subitem
            label="Finally, we add a test datasource, so that our test data doesn&apos;t overwrite the production data."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/test/java/org/jboss/as/quickstarts/html5_mobile/test/MemberRegistrationTest.java,fromLine=59)"/>
  </subitem>
  <subitem
            label="Arquillian allows us to inject beans into the test case."
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/test/java/org/jboss/as/quickstarts/html5_mobile/test/MemberRegistrationTest.java,fromLine=62,toLine=63)"/>
  </subitem>
  <subitem
            label="The test method works as you would expect - creates a new member, registers them, and then verifies that the member was created "
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/test/java/org/jboss/as/quickstarts/html5_mobile/test/MemberRegistrationTest.java,fromLine=68,toLine=76)"/>
  </subitem>

  </item>

  <item
        skip="true"
        title="arquillian.xml">
    <description>
      As you can see, Arquillian has lived up to the promise - the test case is focused on what to test
      (the @Deployment method) and how to test (the @Test method).
      It&apos;s also worth noting that this isn&apos;t a simplistic unit test - this is a fully fledged integration
       test that uses the database.
    <br/><br/>
    Now, let&apos;s look at how we configure Arquillian.
    First of all, let&apos;s take a look at <b>arquillian.xml</b> in <b>src/test/resources</b>.
    </description>
    <subitem
            label="Arquillian deploys the test war to JBoss EAP, and doesn't write it to disk. For debugging, it can be very useful to see exactly what is in your war, so Arquillian allows you to export the war when the tests runs "
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/src/test/resources/arquillian.xml)"/>
  </subitem>
  </item>

    <item
        skip="true"
        title="pom.xml">
    <description>
      Now, we need to look at how we select between containers in the <b>pom.xml</b>.
      <br/><br/>
      Note - Depending on your preferences, when you &apos;Click to perform&apos; the following steps, the pom.xml file opens by default in the &quot;Overview&quot; view. Click on the &quot;pom.xml&quot; view to see the lines of code in the file.
    </description>
    <subitem
            label="The profile needs an id so we can activate from Eclipse or the command line "
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/pom.xml,fromLine=300,toLine=323)"/>
  </subitem>
  <subitem
            label="Arquillian decides which container to use depending on your classpath. Here we define the remote JBoss EAP container. "
            skip="true">
    <command
      required="false"
      serialization="org.jboss.tools.project.examples.cheatsheet.openFileInEditor(path=/${currentProject}/pom.xml,fromLine=325,toLine=347)"/>
  </subitem>

  </item>
  <item
        skip="true"
        title="Arquillian project page">
     <description>
      And that&apos;s it! As you can see Arquillian delivers simple and true testing.
      You can concentrate on writing your test functionality, and run your tests in the same environment in which you will run your application.
      <br/><br/>
      Arquillian also offers other containers, allowing you to run your tests against Weld Embedded (super fast, but your enterprise services are mocked), GlassFish, and more.
      <br/><br/>
      You can find more info on Arquillian on the Arquillian project page.
    </description>
    <command
           required="false"
           serialization="org.eclipse.ui.browser.openBrowser(url=http://www.jboss.org/arquillian)"/>
  </item>

  <item
    skip="true"
    title="Create your own application ">
    <description>
      What we didn&apos;t tell you about the <b>kitchensink-html5-mobile quickstart</b> is that it is generated from a Maven archetype.
      You can use this archetype to generate your own project.
      <br/><br/>
      Simply select <b>Help&gt;Red Hat Central</b> and click the <b>HTML5 Project</b> wizard.
      <br/>
      You will get a brand new project with the same functionality as <b>kitchensink-html5-mobile</b>,
      but customized with your details.
    </description>
  </item>

</cheatsheet>
