Hi Graeme,
I don't know if what follows is the best way... but when I export a file
on my applications sometimes I want to display a progress bar to give users
some feed back... I have done the following:
public abstract class DefaultExportPanel extends Panel {
/**
*
*/
private static final long serialVersionUID = 1L;
private AbstractExportDialogButton button;
private WebMarkupContainer progress;
/**
* @param id
*/
public DefaultExportPanel(String id, AbstractExportDialogButton button) {
super(id);
this.button = button;
setOutputMarkupId(true);
}
@Override
protected void onBeforeRender() {
if(!this.button.getExportTask().isFinished()) {
for(Object behavior : getBehaviors()) {
if(behavior instanceof AjaxSelfUpdatingTimerBehavior) {
remove((AjaxSelfUpdatingTimerBehavior)behavior);
}
}
add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(2)));
progress = new ProgressReportPanel("progress",
DefaultExportPanel.this.button.getExportTask().getProgressReporter());
addOrReplace(progress);
} else {
for(Object behavior : getBehaviors()) {
if(behavior instanceof AjaxSelfUpdatingTimerBehavior) {
remove((AjaxSelfUpdatingTimerBehavior)behavior);
}
}
add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(100)));
progress = new DownLoadExportPanel("progress",
this.button.getExportTask().getFile()) {
private static final long serialVersionUID = 1L;
@Override
public String getContentType() {
return DefaultExportPanel.this.getContentType();
}
@Override
public String getMessage() {
return DefaultExportPanel.this.getDowloadMessage();
}
};
progress.setOutputMarkupId(true);
addOrReplace(progress);
}
super.onBeforeRender();
}
public abstract String getContentType();
public abstract String getDowloadMessage();
}
and the corresponding markup:
<html xmlns:wicket>
<wicket:panel>
<table width="100%" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<div wicket:id="progress"></div>
</td>
</tr>
</table>
</wicket:panel>
</html>
The part:
add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(100)));
progress = new DownLoadExportPanel("progress",
this.button.getExportTask().getFile()) {
private static final long serialVersionUID = 1L;
@Override
public String getContentType() {
return DefaultExportPanel.this.getContentType();
}
@Override
public String getMessage() {
return DefaultExportPanel.this.getDowloadMessage();
}
};
progress.setOutputMarkupId(true);
after removing the behaviors I had to add it because otherwise I would get
an exception when using IE... I know this works, or is working for me with
the snapshot of 1.4.X branch I use, but I'm not sure if its the best way to
achieve this...
Best,
Ernesto
On Sun, Nov 16, 2008 at 10:54 PM, Graeme Knight <[EMAIL PROTECTED]>wrote:
>
> Oh. I'm wondering: https://issues.apache.org/jira/browse/WICKET-1525
>
> Perhaps there is another way?
>
>
> Graeme Knight wrote:
> >
> > Maybe I'm trying to do something silly. Is there an alternative?
> >
> >
> > Graeme Knight wrote:
> >>
> >> Hi.
> >>
> >> What's the best way of achieving this effect:
> >>
> >> 1) Button is pressed to start a process.
> >> 2) Updating of various panels contained within a WebMarkupContainer
> >> occurs on a 5 second period.
> >> 3) Process stops and updating of WebMarkupContainer also stops.
> >>
> >> I understand the use of AjaxSelfUpdatingTimerBehavior - this really is a
> >> question of the best way to add/remove from the WebMarkupContainer on
> >> demand, or enable/disable on demand.
> >>
> >> Any thoughts most welcome.
> >>
> >> Rgds, Graeme.
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Adding-Removing-a-AjaxSelfUpdatingTimerBehavior...-tp20520576p20530559.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>