Page 1 of 1

Data read from database doesn't display

Posted: Tue Mar 25, 2014 8:51 pm
by Shaun

I successfully implemented the appery.io tutorial titled "Using the camera component":
http://docs.appery.io/tutorials/using...

This app uses the camera component to take a snapshot and upload it (and a caption) to a backend appery database. It also displays a list of the uploaded captions.

I decided to take it a step further, as a learning exercise, and add the additional functionality: when the user clicks an item in the list, display the creation date of the photo.

Toward this goal I did the following:

1) Add a 2nd label component (called photoid) to the listitem and make it hidden. The purpose of this is to hold the object_id associated with this photo item in the db

2) Add a label component below the list called photoinfo. The purpose of this is to display the creation date of the photo when a user clicks on a particular item in the list.

3) Import a database read service and call it PhotoDB_photo_read_service. I tested the service (in the test button in the service configuration panel) using a valid object_id and it returns a valid JSON response.

4) Add the read_service to the Data panel of my screen.

5) Edit the read_service mappings. For request, map the photoid text parameter (created in Step 1 above) to the object_id field of the request. For response, map the _createdAt field of the JSON response to the photoinfo text paramter (created in Step 2 above).

6) From the Design panel, click Events and add the following event: upon clicking a photolistitem, invoke the read_service added in Steps 3 and 4.

When I test the modifications (either in the Browser or using the appery.io iPhone app) the app takes pictures and displays the list of captions correctly as before. However, when I click on a caption in the list, a little arrow spins briefly but no creation date information is displayed in the photoinfo component as expected.

I'm new to appery.io and am uncertain how to debug this. I read the documentation about "remote debugging with Weinre" but was unsuccessful in using it (the best I could manage was an error message saying 'You have no permission to view this project').

Am I missing something obvious? If not, what is the best way to debug?


Data read from database doesn't display

Posted: Tue Mar 25, 2014 8:56 pm
by Shaun

I forgot to mention one more step:

7) Modify the mapping of the list_service. In the Response tab, add the additional mapping from _id (JSON response) to the photoid text field created in Step 1. I have verified this mapping works correctly by making temporarily making this component visible.


Data read from database doesn't display

Posted: Wed Mar 26, 2014 1:27 am
by Alena Prykhodko

Hi Shaun.

There is a tutorial which close covers you demands http://docs.appery.io/tutorials/build...

Please look this through to see on example of "delete" service your mistakes and how to implement your purposes correctly in "read" service.


Data read from database doesn't display

Posted: Wed Mar 26, 2014 5:38 pm
by Shaun

Thank you Alena -- I was able to solve my problem after reading the example you cited.

The solution was this:

Upon clicking the list item, I needed to save the id into a local storage variable and then map the local storage variable to the id parameter in the read_service request. Previously, I had mapped the list item component id directly to the read_service request without using an intermediate local storage variable.

Is there an article which explains WHEN i need to use local storage variables and when I can bind service request/response parameters directly to the component? Thanks.


Data read from database doesn't display

Posted: Thu Mar 27, 2014 12:00 am
by Igor

[quote:]
Is there an article which explains WHEN i need to use local storage variables and when I can bind service request/response parameters directly to the component?
[/quote]

Unfortunately there is no such article or doc.
There is more that one solution how you can do this.This tutorials should be helpful:

http://docs.appery.io/tutorials/build...
http://docs.appery.io/tutorials/build...
http://docs.appery.io/tutorials/uploa...

Also please take a look to the main tutorial page: http://docs.appery.io/tutorials/


Data read from database doesn't display

Posted: Thu Mar 27, 2014 6:08 pm
by Shaun

I'll take a look. Thanks, Igor.