How to keep the same request for two pages? - flutter

I have homepage with multiple listItem each item send a request to a server to get the latest update for the specific item (building tracking packages app) so for example you have 10 packages when you enter the app it will send 10 request to the server to get the updated location for them , what i am looking is when the user click in the item itself if the request didn't finish receiving data from the server it will keep that current request even it's in the detail page of that package . so it won't cancel the request and send another one in the detail page if the first request is still active . i hope i am making sense in this question .
I am using Dio for the request

I am getting your point you want when the first request in progress I don't want to send a new request to at this time. you need to do few things when you are doing a request the first time then set a flag true until you do not get response and use the same flag check on your detail page before API call next time.

Related

Postman requests keep creating new conversations

I've deployed the "pizza" dialog to my Bluemix account. I'm using Postman to verify the REST interactions prior to my coding implementation. I'm able to retrieve the dialog id using the dialog REST GET. Taking the returned dialog id I establish a new conversation (leave client_id and conversation_id) empty:
https://gateway.watsonplatform.net/dialog/api/v1/dialogs/ee93cf6e-8718-4524-b10c-4f20fee90883/conversation
I use the returned conversation id to send another conversation request but I first set in the header the conversation_id, and the input value to "A large Pizza"
https://gateway.watsonplatform.net/dialog/api/v1/dialogs/ee93cf6e-8718-4524-b10c-4f20fee90883/conversation
Rather than getting the next turn in the dialog asking for toppings I get a new conversation id and new client id, and input asking me again for what size pizza I'd like to order.
Should I be able to test the dialog interaction using Postman, and why are my subsequent dialog requests all being treated as new conversation requests?
Appreciate any advice.
You said you are setting the conversation ID in the header so I am going to assume you may be passing that ID parameter incorrectly. According to the Watson Dialog API Explorer it states that if you do not pass in a conversation_id it will start a new conversation. Since you pass the converation_id incorrectly it thinks you did not provide one and will start a new conversation with you.
Since you are using Postman, try setting the conversation_id in the Body of the POST and not in the header.

Verify appium current activity response

I verify launched current activity if it's in browser or in app by comparing with current activity.
activity = driverAppium.current_activity
And then I verify if activity matches with browser activity name e.g. org.chromium.browser...
But can I verify the http response on the webpage e.g. 200 or 404?
With above test always passes even though webpage didn't load or get null response.
Can I verify with current activity and response both?
There are two ways to do it what I can think of,
UI prospect :
Capture the screenshot of the webview with 200 response. Let's call it expectedScreen.png
Capture the screenshot of the under test response(be it 200, 400 etc.). Lets call this finalScreen.png
Compare both the images to verify/assert.
API prospect : Since the Activity suppose to be displayed shall never/rarely be changed depending on transitions between different activities on your application as designed, so verifying current activity is a less important check during the test. You can rather verify these using API calls and then(if you get proper response) look for presence of elements on screen accordingly.

GWT panel fields data refresh delay on slow internet

I am using GWT 2.5.1.
In my GWT web app I have a ComplexPanel object which contains a set of fields(widgets). There are a suggested field (on panel) which gives me the opportunity to find object and info about it. Fields (10-15 of them) contain info about that object.
The problem is when user (client side) has a slow internet connection, fields on form are updated with a delay. And if in moment of delay user click 'Save' button (AsyncCallback), old data (which is not updated) posted to the server.
How it works:
1. Server receive callback from the form and start to processing the data.
2. Server refresh all the fields with new data and end the works.
3. Javascript updating the data on form using about 10 requests.
But: internet is slow and one part of data is refreshed and other no.
4. User click SAVE and mixed data goes to the server.
I need to know (from server side) when all the field are refreshed on client side and server can proceed with a next post request.
Thanks in any advice.
Perform a validation check on click of the save button. There are several things you can do as per your requirement. I have listed one way to validate it.
Set a flag before making the async call as false. For instance, isLoaded = false
Once you have all the fields just update it to true, i.e. isLoaded = true
On save button handler check for isLoaded flag. If false, prompt a message, else save.
Update:
You can count the number of response received. You know that you will get 10 response. So for every response received increment a counter. Activate save only if you have all 10 response recieved.
For a clean way to do this, use gwt-async-future.

Prevent resubmit a form and struts

I have two jsp page: page1.jsp with a form and page2.jsp which displays a message to tell the user if the record insert happened or not.
If the form is successfully submitted and the user refreshes the page2, another insert happens.
I wouldn't to use a session variable, and setting a request attribute in the page2 doesn't resolve the issue (it seems to not work).
You can give a try to this:
From page1.jsp set a request attribute, when control reaches to
page2.jsp check for that request attribute if it is there redirect the
control to same page2.jsp. In this way when control is redirected to
same or other resource, previous request and response objects are no
more there(i.e. both request and response object will destroy because
HTTP is stateless protocol) And like this after redirection there will
be no data related to previous request and on refreshing the page2.jsp it
will not repeat the previous task.
I am not sure but in one of my application I used the same for the purpose. Let me know if anyone has a better alternative.

grails show wait page on form submit

I have a form that the user submits and returns a result, but it takes a couple of seconds to return the result. I know I can use grails formRemote http://grails.org/doc/latest/ref/Tags/formRemote.html to execute the call asynchronously and update a div on the page, but what I want to do is show another page entirely (with some wait graphics and other information).
Is there an easy way to do this in grails?
You can send data to server asynchroniously (ajax, formRemote), showing 'wait graphics' util you get a response. And redirect to result page right after getting response (and you should have to store state somewhere, and probably have unique url for result page)