You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris Merrill <ch...@webperformance.com> on 2010/08/25 20:03:45 UTC

ProgressBar, AjaxRequstTarget and making a containers contents visible

I have a page that shows the progress of a long-running process using
WicketStuff ProgressBar.  Works great!  (AFAICT).

When the process is finished, I want to make the results section of
the page visible (it is initially invisible).  The results section is
a WebMarkupContainer containing text that should become visible when
the process is complete. I've put updates into the "onFinished()" method of
ProgressBar, but my results section does not become visible.  I've tried a
number of variations of page structure, but haven't found one that works...
perhaps that part is fine and I'm missing something else.

My debug statements indicate that the onFinished() method is being invoked
and completing successfully (oddly, it is called twice).  The progress bar
moves as expected.  The label on my button changes from "Ready" to "Running"
and then to "Done" (that final update is done in onFinished()).

Below are my page code and HTML.  I've tried to pare it down to the simplest
possible example.  Can anyone see where I've gone wrong?  The StatusGenerator
class, not included here, simply provides status changes over a period of
time in a separate thread.

TIA!
Chris


----------------------------------------------------------------------
StatusPage.java
----------------------------------------------------------------------


package com.webperformanceinc.office.licmgr.ui;

import com.webperfcenter.util.*;
import com.webperformanceinc.office.licmgr.model.*;
import com.webperformanceinc.office.ui.*;
import org.apache.wicket.ajax.*;
import org.apache.wicket.ajax.markup.html.form.*;
import org.apache.wicket.markup.html.*;
import org.apache.wicket.markup.html.basic.*;
import org.apache.wicket.markup.html.form.*;
import org.apache.wicket.model.*;
import org.wicketstuff.progressbar.*;

public class StatusPage extends BaseLicenseManagerPage
    {
    public StatusPage()
        {
        super("Example_Page");
        _generator = new StatusGenerator();

        WebMarkupContainer container = new WebMarkupContainer("container");
        container.setOutputMarkupId(true);
        add(container);

        Form form = new Form("form");
        container.add(form);

        ProgressionModel progress_model = new ProgressionModel()
            {
            protected Progression getProgression()
                {
                return _generator.getProgress();
                }
            };
        final ProgressBar bar = new ProgressBar("bar", progress_model)
            {
            protected void onFinished(AjaxRequestTarget target)
                {
                _start_button_label.setObject("Done");
                _start_button.modelChanged();
                target.addComponent(_start_button);

                _result.setObject(_generator.getResult());
                _result_label.modelChanged();
                target.addComponent(_result_label);
                _result_section.setVisible(true);
                target.addComponent(_result_section);
                Debug.log.out("StatusPage.onFinished() - made it visible.");
                }
            };
        form.add(bar);
        bar.setOutputMarkupId(true);

        _start_button = new AjaxButton("start_button", _start_button_label, form)
            {
            protected void onSubmit(AjaxRequestTarget target, Form form)
                {
                bar.start(target);
                _generator.start();
                _start_button_label.setObject("Running");
                _start_button.modelChanged();
                target.addComponent(_start_button);
                }
            };
        _start_button.setOutputMarkupId(true);
        form.add(_start_button);

        _result_section = new WebMarkupContainer("result");
        _result_section.setOutputMarkupId(true);
        _result_section.setVisible(false);
        form.add(_result_section);

        _result_label = new Label("name", _result);
        _result_label.setOutputMarkupId(true);
        _result_section.add(_result_label);
        }

    private AjaxButton _start_button;
    private Model<String> _start_button_label = new Model<String>(getText("Start"));

    private WebMarkupContainer _result_section;
    private Label _result_label;
    private Model<String> _result = new Model<String>("nobody");

    private transient StatusGenerator _generator;
    }


----------------------------------------------------------------------
StatusPage.html
----------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:wicket="http://wicket.sourceforge.net/">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>app title</title>
  </head>
  <body>
      <wicket:extend>

<wicket:container wicket:id="container">
<div align="center">
<form action="#" wicket:id="form">

    <div wicket:id="bar">[progress bar]</div>
    <p></p>
    <p>
    <input type="submit" wicket:id="start_button" value="start">
    </p>

    <wicket:container wicket:id="result">
          <p><span wicket:id="name">name</span> is Done</p>
    </wicket:container>

</form>
</div>
</wicket:container>


      </wicket:extend>
  </body>
</html>




-- 
------------------------------------------------------------------------ -
Chris Merrill                           |  Web Performance, Inc.
chris@webperformance.com                |  http://webperformance.com
919-433-1762                            |  919-845-7601

Web Performance: Website Load Testing Software & Services
------------------------------------------------------------------------ -

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org