You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Graeme Knight <gr...@gmail.com> on 2008/11/16 00:23:40 UTC
Adding/Removing a AjaxSelfUpdatingTimerBehavior...
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...-tp20520576p20520576.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Adding/Removing a AjaxSelfUpdatingTimerBehavior...
Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi Graeme,
On Mon, Nov 17, 2008 at 2:58 PM, Graeme Knight <gr...@gmail.com> wrote:
>
> Hi.
>
> Thanks for that. I was worried about removing behaviors - but thanks for
> the
> information.
You are welcome!
>
>
> I'm going to look at how easy it is to change time on an
> AjaxSelfUpdatingTimerBehavior?
>
I don't remember if I have tried that. I remember I tried removing
the AjaxSelfUpdatingTimerBehavior and then got some error on IE (was sending
back a request to the non-existing behavior). So I started playing with it
till I discovered that recreating the behavior and putting a long refreshing
time "fixed" this (100 seconds was long enough for me because the content
fetch from the server was small enough, but maybe I should make it
bigger;-). So, there should be a better solution... as this looks like a
"hack". I didn't spend much time investigating what was going on wrong...
> I need a poll anyway so I am thinking of polling once every five minutes
> and
> then when the refresh is occurring I can poll evey 5 seconds, then when
> finished - back to five minutes...
>
> Cheers, Graeme.
>
>
Cheers,
Ernesto
> reiern70 wrote:
> >
> > 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
> > <gr...@gmail.com>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: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Adding-Removing-a-AjaxSelfUpdatingTimerBehavior...-tp20520576p20539844.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Adding/Removing a AjaxSelfUpdatingTimerBehavior...
Posted by Graeme Knight <gr...@gmail.com>.
Hi.
Thanks for that. I was worried about removing behaviors - but thanks for the
information.
I'm going to look at how easy it is to change time on an
AjaxSelfUpdatingTimerBehavior?
I need a poll anyway so I am thinking of polling once every five minutes and
then when the refresh is occurring I can poll evey 5 seconds, then when
finished - back to five minutes...
Cheers, Graeme.
reiern70 wrote:
>
> 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
> <gr...@gmail.com>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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Adding-Removing-a-AjaxSelfUpdatingTimerBehavior...-tp20520576p20539844.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Adding/Removing a AjaxSelfUpdatingTimerBehavior...
Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
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 <gr...@gmail.com>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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Adding/Removing a AjaxSelfUpdatingTimerBehavior...
Posted by Graeme Knight <gr...@gmail.com>.
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Adding/Removing a AjaxSelfUpdatingTimerBehavior...
Posted by Graeme Knight <gr...@gmail.com>.
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...-tp20520576p20527143.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org