KK
Posts: 0
Joined: Fri Mar 13, 2015 11:59 pm

Application is not working in offline mode

Hello Team,
I have an application which has just a date calculation

Input1 is a date
Input2 is a date

and response on button click is Input1 - Input2 - SO no data base connection required

I am using REST service to do the calculation.

This application is working perfectly fine in online mode but when I am offline it is not working at all.

I read about echo but as far as I understood it is used only when you want to sync the data with database.

I am new to Apperyio so may be its a simple setting somewhere.
Can you please help.

Regards

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Application is not working in offline mode

Hello KK,

Could you please detail, did you try this tutorial: http://devcenter.appery.io/tutorials/... ?

KK
Posts: 0
Joined: Fri Mar 13, 2015 11:59 pm

Application is not working in offline mode

Hi Evgene,
Thanks for the quick reply,
on the button-event -click - I have the invoke service connected to a service

service:

input1 = datepicker 1 value
input2 = datepicker2 value

Output is a response with some value
This is the code I have in the server code script

// get date from first conception from service
var input1= request.get("input1");
var input2= request.get("input2");

var inputdate1 = new Date(input1);
var l1 = inputdate1.getDate();
var m1 = inputdate1.getMonth();
var n1= inputdate1.getFullYear();

var ConvertInput1= new Date(n1, m1, l1, 00, 00, 00, 00);

var Timesince1970andInput1= ConvertInput1.getTime();

var inputdate2 = new Date(input2);
var l2 = inputdate2.getDate();
var m2 = inputdate2.getMonth();
var n2= inputdate2.getFullYear();

var ConvertInput2= new Date(n2, m2, l2, 00, 00, 00, 00);

var Timesince1970andInput2= ConvertInput2.getTime();

var RemainingWeeksTime = Timesince1970andInput2 - Timesince1970andInput1;

var RemainingWeeks = Math.round(RemainingWeeksTime/604800000);

var greetingString = RemainingWeeks ;

// format as JSON and return the response
response.success(JSON.stringify({
Result: greetingString
}), "application/json");

This is working file when I am connected to internet but not offline.
Please let me know what can be done.

Thanks in advance
Regards

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Application is not working in offline mode

Hello -

[quote:]
I am using REST service to do the calculation.
[/quote]

As long you working with REST service, it won't work in offline, as its works on http protocols.

KK
Posts: 0
Joined: Fri Mar 13, 2015 11:59 pm

Application is not working in offline mode

So, I need to write entire code in javascript on button click to make it work in offline mode.

Or should I make a generic service to make it work in offline mode ?

Regards

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Application is not working in offline mode

As Evgeny mentioned you will need to write a JavaScript code that will check the connection, like for example in our tutorial -- http://devcenter.appery.io/tutorials/...

KK
Posts: 0
Joined: Fri Mar 13, 2015 11:59 pm

Application is not working in offline mode

Hello,
Can you please tell me how can I make this app(from your tutorial) work in offline mode if possible

http://devcenter.appery.io/tutorials/...

Regards

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Application is not working in offline mode

Hi,

Unfortunately we do not have offline example for this tutorial http://devcenter.appery.io/tutorials/...
You can try to implement this yourself, if have exact question do not hesitate to ask.

KK
Posts: 0
Joined: Fri Mar 13, 2015 11:59 pm

Application is not working in offline mode

Hello Alena,
Thanks a lot for your reply.
Actually I have gone through this code and built an app on the basis of this example which calculated number of weeks between 2 different input dates.

I have no database input but only 2 front end input and then calculation so I am wondering do i really need to use echo or Generic request.

I thought there should be a logic to just calculate on the basis of input without server refresh as I am not using database but I use REST service which is creating problem and because of them it is not working in offline mode.

I am still trying
1) to understand the offline mode tutorial
2) to run my app without REST code by taking all code in the button click -run javascript

I dont know it will work and how it will work :)

Let me know if I am going in the right direction in changing the entire code in javascript instead of using services.

Thanks in advance

PS: I have just started learning , Apologies for the stupid questions if there are some :)

Egor Kotov6832188
Posts: 0
Joined: Wed Nov 19, 2014 5:15 pm

Application is not working in offline mode

Hello KK,
Let me know if I am going in the right direction
yes, this is one of possible implementations, but the most efficient way is to make it with generic service, cause then you can map it to page or to LSV by simply dragging fields from the response.
If you just want to make simple calculation, then simple JS will also work

Return to “Issues”