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

  • Home
  • SEARCH
  • 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 8668121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:08:11+00:00 2026-06-12T18:08:11+00:00

I have a case where I need to update a gui component based on

  • 0

I have a case where I need to update a gui component based on operations performed in another thread. For this I have the following:

A class that extends WebPage and creates an input field, a form and a label. When the form is submitted a thread that processes data from the input file is started and an AbstractAjaxTimerBehavior is attached to the page which updates the label with the progress/status of the thread.

Because I cannot access the thread object in the onTimer () method of the ajax timer, I pass on a reference of the class to the thread upon it’s creation. The thread then updates a variable (status) of the class with it’s progress. What the ajax timer does is it updates the label’s value with the status value.

public int status;

@Override
public void onSubmit ()
{
    final Task task = new Task (ViewPage.this);
    Thread thread = new Thread (task);
    thread.start ();

    AbstractAjaxTimerBehavior timer = new AbstractAjaxTimerBehavior (Duration.milliseconds (1000))
    {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onTimer (AjaxRequestTarget target)
        {
            System.out.println ("> Progress [" + status + "]");

            if (status == x)
            {
               // refresh page
               setResponsePage (getPage().getClass ());
            }
        }
    };

    getPage().add (timer);
}

Is there a way that I can update the label’s value by accessing the thread object directly from the ajax timer or in a clean way?

  • 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-12T18:08:12+00:00Added an answer on June 12, 2026 at 6:08 pm

    I found a good answer here: Wicket countdown timer will not self-update

    I created a model class that has status member. Then create an instance of this class and set it as Label’s model and also pass it to the thread to update the status value. Then in the onTimer () method add the label to be updated.

    public class ProgressModel implements IModel<String>
    {
        private static final long serialVersionUID = 1L;
    
        public String status;
    
        @Override
        public void detach ()
        {
            // TODO Auto-generated method stub
        }
    
        @Override
        public String getObject ()
        {
            return status;
        }
    
        @Override
        public void setObject (String object)
        {
            status = object;
        }
    }
    

    Create model instance and set it to the Label object

    pm = new ProgressModel ();
    statusLbl = new Label ("statusLbl", pm);
    statusLbl.setOutputMarkupId (true);
    

    In the onTimer () method of the AbstractAjaxTimerBehavior just set the Label object to be updated

    @Override
    protected void onTimer (AjaxRequestTarget target)
    {
        target.add (statusLbl);
    }
    

    In the thread class I have:

    class Task implements Runnable
    {
        public Task (ProgressModel progressModel)
        {
            this.pm = progressModel;
        }
    
        @Override
        public void run ()
        {
            // some operations
            pm.status = x;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a case where I need to update a jqgrid based on some
So I have this SQL table that I need to update. Now we use
I have a very specific case that I need to debug. I need to
Currently I have a legacy based non-MVC php framework which I need to update
I have a case where I need to update the title of a jQuery
I have a ListView that I need to update by adding an item. Using
I have following entities: In my code I need to update the FKCategoryID in
I have a case where I need to select a random item, but I
I have a case where I need to load bitmap from a resource dll
I have a use case where I need to call a (non-static) method in

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.