Skip to content

vetrip/BookClient

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Overview

DISCLAIMER: THIS IS SAMPLE CODE AND NOT PRODUCTION QUALITY CODE!

Before running this sample, the BookService sample needs to be running locally on your computer or published to the cloud. For more information, see BookService

This sample is a client application that makes HTTP requests to the BookService project. You can view, create, edit and delete books stored in a Mongo backend database via the BookService.

This sample runs on either Android 3.0 (API 11) and later or iOS, and was tested against Titanium SDK 3.1.0.GA and Alloy 1.1.2.

This sample provides two sync adapters--REST and Node.ACS. The REST adapter directly makes HTTP requests to the service, while the Node.ACS adapter uses a bindings file generated by the Node.ACS CLI to make JavaScript API calls to access the service.

Importing the Project into Studio

Clone this repo, create a new Alloy project, then import the cloned repo into the newly created Alloy project.

  1. From the menu bar, select File > New > Mobile Project. The New Mobile Project wizard appears.
  2. Select Alloy > Default Alloy Project. Click Next.
  3. Fill out all fields and click Finish.
  4. From the menu bar, select File > Import. The Import wizard appears.
  5. Select General > File System. Click Next.
  6. For From directory, click Browse, navigate to the cloned repo, then click Open.
  7. Select the app folder, that is, checkmark the item.
  8. For Into directory, click Browse, select the newly created project, then click OK.
  9. Click Finish.

Studio creates a new Alloy project and imports the files into it.

Configuring the Client Application

Add the following to the Android manifest section of your tiapp.xml file:

<android xmlns:android="http://schemas.android.com/apk/res/android">
    <manifest>
        <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="11"/>
    </manifest>
</android>

Then, modify the model file to use either the REST or ACS sync adapter.

Using the REST Sync Adapter

Modify app/model/book.js to use REST adapter:

  1. Change the config.adapter.type key to book_rest.
  2. Change the config.adapter.base_url key to the endpoint URL of the BookService, for example, http://localhost:8080/book/.

Note: You NEED the /book/ part of the URL.

Using the Node.ACS Sync Adapter

Modify app/model/book.js to use Node.ACS adapter. Change the config.adapter.type key to book_acs.

Add the following key to your tiapp.xml file and replace the URL with your endpoint URL for BookService:

<property name="acs-service-baseurl-BookService">https://localhost:8080</property>

Note: You do NOT need the /book/ part of the URL.

Running the Client Application

Before running the client application, the BookService project either needs to be running locally on your computer or published to the cloud.

In Studio,

  1. Select your project in the App Explorer or Project Explorer view.
  2. Click the Run button and select either the Android Emulator or iPhone Simulator.

Studio launches the client application on the selected platform.

Testing the Client Application

The client application uses the native controls of the Android and iOS platform to add a book or refresh the table.

  • For Android, use the Menu button to activate the action bar. Select Add to add a book or Refresh to refresh the view.
  • For iOS, use the window's right navigation button (Add) to add a book and drag the table down to refresh the view.

To close a window, use the Back button on the Android platform and the window's right navigation button (Close) on the iOS platform.

To modify or delete a book, click on the book title in the table, then:

  • To modify the book, make your modifications and click Save Edits.
  • To delete the book, click Remove.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published