2
votes

Here the NextPage form is opened when btn is clicked. Then after when I click the back button, the connection is again requested to open previous form (ie "Home"). It will take both time and data to do that. So what I want is that once the connection is done, i dont want to establish a connection again when back to the same form. How can i accomplish that?

@Override
protected void beforeHome(Form f) {
 btn.addActionListener((e)->{

  public void connectionForEmergencyListDetails(Form f, String categoryIdInt) {
    ConnectionRequest emergencyConnectionRequest = new ConnectionRequest() {

        @Override
        protected void postResponse(InputStream input) throws IOException {
           showForm('NextPage',null);
        }

    }
  }
 });
}

What I tried is that I stored the data in cache (storage) and it works in offline mode as well. But when there is a network connection, it establishes connection every time i go to the form. I don't want to establish the connection again when i go back to the same form since the data are already displayed and stored too in my case.

1

1 Answers

1
votes

That code doesn't compile. You add a method into a lamba closure and you don't call the addToQueue.

I'm guessing that what you are looking for is Storage.exists which allows you to determine if you already have something in storage for the connection.