Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6977013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:34:16+00:00 2026-05-27T17:34:16+00:00

I am working on GWT + JAVA. I have a piece of code in

  • 0

I am working on GWT + JAVA.

I have a piece of code in GWT as below

static int DELAY = 1000;

private void downloadAttachments(final List<String> ftIdList) 
{
   try
   {
      Timer timer = new Timer() 
      {
         @Override
         public void run() 
         {
            int cnt = 1;
            for (String url: ftIdList)
            {
               String windowName = "win" + cnt;
               Window.open(url, windowName, "");
               cnt++;
               scheduleRepeating(DELAY*2);
            }
            cancel();
         }
      };
      timer.run();
   }
   catch (Throwable exc) 
   {
      Window.alert(exc.getMessage());
   }
} 

I need to open several windows to allow a user to download all files.

I am calling a Servlet.

How can I introduce a delay in the loop until the next iteration?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:34:16+00:00Added an answer on May 27, 2026 at 5:34 pm

    Here is solution, in same style as maks suggests by using property for keeping the state of the counter. You still have the loop just in different way.

    private void downloadAttachments(final List<String> ftIdList) {
        final int size = ftIdList.size();
    
        Timer timer = new Timer() {
    
            private int counter = 0;
    
            @Override
            public void run() {
            if (counter == size) {
              cancel();
              return;
            }
            String url = ftIdList.get(counter);
            String winName = "win" + counter;
            Window.open(url, winName, "");
            counter++;
            }
        };
        timer.scheduleRepeating(2000);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a GWT project, and I have a bunch of Java classes
I'm working on checkBoxTree in GWT-EXT 2.0.3 with Java. My aim is to get
I'm working on a medium-sized project in Java (GWT to be precise), and I'm
I'm working on my first GWT-based Java project for a school assignment. It's a
Something I have found strange since I started working on GWT is how few
I have a running Java GWT application, that I can compile using Eclipse. Now
I've been working with Java for a long time but never have come across
I am working with GWT 2.2, JPA, Java EE 6 Web, glassfish v3. My
We have our gwt application working fine on the development mode with gwt 2.4rc1
I require a source code obfuscator for Java that is working on windows 7.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.