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 9318901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:15:02+00:00 2026-06-19T03:15:02+00:00

I am trying to set up a background service that would perform bulk loading

  • 0

I am trying to set up a background service that would perform bulk loading of transaction data from a csv file. This background service would be initiated from a menu item action mapped to a method in the controller/presenter class.

Ever so often, some data turns up in the csv file for which no master data can be found in the database, this would normally cause the upload to choke and fail.

On such occasions, I would like to be able to have the background service pause its processing and invoke a dialog from a presenter class to take in user input. The user input would be used to add a master row in the database, after which the background service should resume from where it had left off (not from the beginning of the csv file, but from the row which caused the error).

Is this possible to achieve in JavaFX, perhaps with the javafx.concurrent API? How would I go about doing this?

  • 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-06-19T03:15:04+00:00Added an answer on June 19, 2026 at 3:15 am

    Solution

    When your background process encounters a situation where it requires a user to be prompted for input, use FutureTask executed in Platform.runLater to showAndWait the dialog prompt on the JavaFX application thread. In the background process use futureTask.get to pause the background process until the user has input the necessary values which will allow the process to continue.


    Sample Code Snippet

    Here is the essence of code for this approach which can be placed inside the call method of your background process:

    String nextText = readLineFromSource();
    if ("MISSING".equals(nextText)) {
      updateMessage("Prompting for missing text");
      FutureTask<String> futureTask = new FutureTask(
        new MissingTextPrompt()
      );
      Platform.runLater(futureTask);
      nextText = futureTask.get();
    }
    ...
    class MissingTextPrompt implements Callable<String> {
      private TextField textField;
    
      @Override public String call() throws Exception {
        final Stage dialog = new Stage();
        dialog.setScene(createDialogScene());
        dialog.showAndWait();
        return textField.getText();
      }
      ...
    }
    

    Sample Application

    I created a small, complete sample application to demonstrate this approach.

    The output of the sample application is:

    promptingtaskdemooutput

    Sample Output Explanation

    Lines read without missing values are just plain brown.
    Lines with a prompt value entered have a pale green background.
    Fourteen lines have been read, the background task has already paused once at the 6th line which was missing a value. The user was prompted for the missing value (to which the user entered xyzzy), then the process continued until line 14 which is also missing and the background task is again paused and another prompt dialog is being displayed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set the background color of a UIImageView with this (It should
I'm trying to set the background of the right arrow, that when I press
I am trying to set the row background color for the advanced data grid
I'm trying to set an image as a background image. From what I've read
Im trying to set the background color of a div tag that resides in
I am trying to set the background image of a panel that is added
I am trying to set up an alarm that will run in the background
Hi I'm trying to make a service that runs in the background after the
I'm trying to start an activity from a service running in background but its
I'm trying to set the background image of canvas using canvas.setBackgroundImage(image); How can i

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.