Appery.io new HTML5 app builder has been the default builder for the past couple of weeks and we continue to update it with new features. One such feature is new Windows 8 support. In addition to jQuery Mobile/PhoneGap apps, you can now build Windows 8 apps with native support such as Snap View, Search Charm, Share Charm, and Live Tile.
To create a new Windows 8 app, click the “More create options” link from the Apps page and then select Windows 8 App as the app type. Try our Windows 8 app tutorial.
jQuery Mobile 1.2
We also upgraded to a much better jQuery Mobile version 1.2.
We also upgraded PhoneGap to version 2.2. This means Appery.io cloud build has also been upgraded to PhoneGap 1.2:
You should use Firefox to build and test the app in the browser. IE10 support is coming
In this tutorial, we are going to build a Windows 8 app to search Twitter. We will use the Twitter search REST API to find all tweets using a term entered in the app.
Creating a new Windows 8 project
To start, let’s create a new Windows 8 project.
Sign into Appery.io.
Click on APPS in the upper-right-hand corner of the screen.
Click on the More create options link to the right of the Create button.
In the new screen, enter an app name. Let’s use “TwitterWindows8″.
Select the Windows 8 App radio button.
Click Create to open the new project in the new builder. (It should display a welcome screen as shown below.)
Creating the UI
We will create the UI by dragging and dropping components from a left sidebar palette and setting component properties from a right-hand sidebar.
Using the left sidebar, expand Pages and select home. In the middle of the screen, you will see this:
Click the black screen.
In the right (Properties) sidebar under Custom, find the Rows field and make the entry “120px;auto;1fr”. A new row will appear.
From the Design (components) palette to the left, select an input component under Controls and drop it inside the cell at the first row/second column:
The result will then look like this:
Select the new input and then click the icon (as shown) to select the parent container:
Under Custom properties, set Column align to “start”.
Now select a button component from under Controls and drop it inside the cell at the second row/second column.
Select the new button’s parent container by clicking the icon as you did for the new input and set Column align to “start”.
Select the button and change its label by entering “Search” into the Text field under Common properties.
You can also now test the app by clicking the Test button in the upper-right corner of the browser screen.
Note: We recommend Firefox for previewing the app. We are still working on IE 10 support.
Now, let’s continue building the UI by adding a listview component. Select a listview component from the Containers components and then drop it inside the cell at the third row/second column.
Select the component and, under Common properties, change the Height to “160px”.
Next, select a grid component from the Layouts components and drop it inside the listview.
With the grid selected, set the Rows field under Custom properties to “auto;auto;auto”.
Then, set its size by entering these values into these fields under Commonproperties:
Select an image component from the Controls components and drop it into the first row/first column of the grid you just created.
Select the image component’s parent (via the small icons) and set its Column align to “start”.
Select a label component from the Controls components and drop it into the second row/first column of the grid.
Select the label’s parent (via the small icons) and set its Column align to “start”.
Reselect the label and set the Text field under Common properties to be blank.
Select another label component from the Controls components and drop it into the third row/first column of the grid.
Select this label’s parent (via the small icons) and set its Column align to “start”.
Then, reselect the label and set the Text field under Common properties to be blank.
(Saving is not required till the end, but, if you want, you can save at the end of each section by clicking on the Save button in the top menu bar of the editor.)
Creating a service
We’ll now create a Appery.io “service” component (service interface) that can be used in building our app. We’ll use a Twitter Search REST service for our service component. We just need to define some things about the service and specify the request and response parameter we’ll be using for input and output.
In the upper-left part of the screen, click on Create New and then click on “Service” from the drop-down menu.
Enter “TwitterSearch” as the name and click the Create Service button.
If you look on the left-hand side, you’ll see the new service listed under Services. Click on this TwitterSearch label to open the service editor on the service.
Now, under the REST Service Properties section, enter “http://search.twitter.com/search.json” as the URL and select “jsonp” as the Data Type.
Open the Request Parameters section underneath this section by clicking on Request Parameters.
Enter “q” into the text input box and click Add.
Open the Response Parameters section underneath this section by clicking on Response Parameters.
Enter “results” into the text input box and click Add.
Click the green + button in the same row as the results response parameter to make a sub-element of results.
Enter “profile_image_url” into the new text input box and click Add. The result will look like this:
Click the green + button in the same row as the results response parameter again to make another sub-element of results.
Enter “from_user” into the new text input box and click Add.
Then, click the green + button in the same row as the results response parameter one last time to make another sub-element of results.
Enter “text” into the new text input box and click Add.
The result will look like this:
Mapping the service to the UI
Now, we have REST service parameters on one side and UI components on the other side. Next, we’ll connect them together in the Data section of the editor as a data mapping called “restservice” that uses the service component called “TwitterSearch”.
Select the home tab above the service editor.
Click on the Data side-tab.
From the Type drop-down menu, select “Service”.
From the Component drop-down menu, select “REST Service”.
Click the green button to the right.
In the row that will have appeared under Components List, click the blue Edit Mapping… button
A Component Properties sidebar will appear to the right. From the Service drop-down menu, select “TwitterSearch”.
Now click the Edit Mapping… button again. A new screen, the mapping editor, will scroll in from the right with the Request Mapping tab selected.
On the right-hand side under Components, expand home and then expand the first sub-item under it.
Click on the q parameter on the left-hand side, drag the cursor to the label Text under the expanded sub-item, and drop.
The input component is now mapped to the REST service input.
Now click on the Response Mapping.
Expand results on the the left-hand side, collapse the input component on the right-hand side, and expand the listview component and it’s subitems until everything is exposed.
Then, using the same drag-and-drop approach as above, define the following mappings:
The results parameter is the collection of all tweets found through the query. We are mapping it to the parent listview container to get automatic looping. The rest of the mappings are straightforward.
Invoking the service
We are almost done. We have a UI, a service component for using a REST service from the app, and a data mapping connecting the UI and the service together. All we need is a triggering event for the data mapping to invoke the service. For this we’ll use a panel hidden away at the bottom of the screen.
Select the Design side-tab.
Find the Show Events Panel tab all the way in the bottom-right corner of your screen.
Click this tab to open the events panel.
From the Component drop-down menu, select the button component.
From the Event drop-down menu, select “Click”.
From the Action drop-down menu, select “Invoke Service”.
From the Service drop-down menu select “restservice” (the service data mapping you created).
Click the green button to add this event.
You have now set up the app to invoke a service through clicking the Search button in the app.
Testing the app
Now we can test the app. Just click the Test button in the upper-right corner of the screen and enter any term to search for. You should get a result that looks something like this:
Last week we put posted Building a Mobile Search App with Appery.io Database tutorial that shows you how to search a database for a particular search term. The way the search worked, is that the entire word has to be matched. For example, you could enter ‘Apple’ but not ‘Ap’ to search. In this post we are going to show you how to use a regular expression to get all objects that start with a particular letter. As for our data, are going to use US States.
Building the UI
To start, the UI that we need looks like this:
For input we use a search component
Below the input we have a grid, with one column and a label inside.
That’s all we need for the UI. Let’s now create the database.
Creating a database
Create a new database by going to http://appery.io.
Go to Collections tab and click Import button.
Upload States CSV file to the database. Once the collection is created, it should look like this:
That’s it for the database. Let’s now add a REST service to search this collection.
Adding a REST service
In Appery.io app builder, select Project > Create New > Database Services
Select your database
Expand States collection and check Query service.
Click import Selected services button. A query search for States collection will be created.
Let’s test the service. As we want to make the search a little bit more flexible, we are going to use a regular expression. For where param, enter the following:
The above will return all states that start with letter C or c. “$options”:”i” is what specifies the query to ignore the case.
We are done with the service. Let’s move on to mapping.