You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Zbynek Vavros <zb...@gmail.com> on 2018/05/30 12:05:47 UTC

Paint UI before starting long running task

Hi,

I got a wizard and one of its steps display loading image while
processing long running task. After this task JavaScript is being called.

I've put the code into render renderHead() method of the step itself:

@Override
public void renderHead(IHeaderResponse response) {
    // process task
    String taskResult = ...
    // call JavaScript with result
    response.render(OnDomReadyHeaderItem.forScript("jsFunction(" +
taskResult + ")"));
}

When I click the NEXT button, this long running task is executed before
the step with loading image is rendered.
I guess I need to move the code somewhere else than renderHead() but where?

Thanks,
Zbynek

Re: Paint UI before starting long running tasked

Posted by Zbynek Vavros <zb...@gmail.com>.
I did used a nasty way by using AjaxLazyLoadPanel and providing my custom
loading as both - lazy load component (with code in renderHead) and loading
component (empty renderHead) . Not the most elegant way but from user point
of view its ideal :)

Zbynek

On Thu, May 31, 2018, 16:25 Martin Grigorov <mg...@apache.org> wrote:

> On Wed, May 30, 2018 at 6:00 PM, Zbynek Vavros <zb...@gmail.com>
> wrote:
>
> > Hey,
> >
> > this is weird, I can see the Ajax loading during renderHead() processing
> > and then switch to my loading.
> >
> > Maybe I could describe what I'm doing in more details (with
> > AjaxLazyLoadPanel  being used):
> > Loader from AjaxLazyLoadPanel is displayed.
> > Remote REST is being called, response from REST is passed to JS function
> -
> > at this moment my panel is rendered.
> > JS then calls remote service via websocket, receives response, passed
> that
> > response to Wicket JS callback function.
> > This calls yet another REST endpoint and saves result into DB.
> >
> > After that I replace my loading with success message.
> >
> > I would like to "ideally" have all this covered by single loading panel.
> >
>
> You will need to create a custom Panel to do all this.
> I guess you can still use AjaxLazyLoadPanel if you use Java WebSocket
> client, but this is something you have to decide.
>
>
> >
> > Zbynek
> >
> >
> > On Wed, May 30, 2018 at 3:32 PM, Martin Grigorov <mg...@apache.org>
> > wrote:
> >
> > > Hi,
> > >
> > > Do you use AjaxLazyLoadPanel for the loading image + result panel ?
> > > You can move your #renderHead() logic to the result panel's
> renderHead().
> > >
> > > On Wed, May 30, 2018 at 3:05 PM, Zbynek Vavros <zbynekvavros@gmail.com
> >
> > > wrote:
> > >
> > > > Hi,
> > > >
> > > > I got a wizard and one of its steps display loading image while
> > > > processing long running task. After this task JavaScript is being
> > called.
> > > >
> > > > I've put the code into render renderHead() method of the step itself:
> > > >
> > > > @Override
> > > > public void renderHead(IHeaderResponse response) {
> > > >     // process task
> > > >     String taskResult = ...
> > > >     // call JavaScript with result
> > > >     response.render(OnDomReadyHeaderItem.forScript("jsFunction(" +
> > > > taskResult + ")"));
> > > > }
> > > >
> > > > When I click the NEXT button, this long running task is executed
> before
> > > > the step with loading image is rendered.
> > > > I guess I need to move the code somewhere else than renderHead() but
> > > where?
> > > >
> > > > Thanks,
> > > > Zbynek
> > > >
> > >
> >
>

Re: Paint UI before starting long running task

Posted by Martin Grigorov <mg...@apache.org>.
On Wed, May 30, 2018 at 6:00 PM, Zbynek Vavros <zb...@gmail.com>
wrote:

> Hey,
>
> this is weird, I can see the Ajax loading during renderHead() processing
> and then switch to my loading.
>
> Maybe I could describe what I'm doing in more details (with
> AjaxLazyLoadPanel  being used):
> Loader from AjaxLazyLoadPanel is displayed.
> Remote REST is being called, response from REST is passed to JS function -
> at this moment my panel is rendered.
> JS then calls remote service via websocket, receives response, passed that
> response to Wicket JS callback function.
> This calls yet another REST endpoint and saves result into DB.
>
> After that I replace my loading with success message.
>
> I would like to "ideally" have all this covered by single loading panel.
>

You will need to create a custom Panel to do all this.
I guess you can still use AjaxLazyLoadPanel if you use Java WebSocket
client, but this is something you have to decide.


>
> Zbynek
>
>
> On Wed, May 30, 2018 at 3:32 PM, Martin Grigorov <mg...@apache.org>
> wrote:
>
> > Hi,
> >
> > Do you use AjaxLazyLoadPanel for the loading image + result panel ?
> > You can move your #renderHead() logic to the result panel's renderHead().
> >
> > On Wed, May 30, 2018 at 3:05 PM, Zbynek Vavros <zb...@gmail.com>
> > wrote:
> >
> > > Hi,
> > >
> > > I got a wizard and one of its steps display loading image while
> > > processing long running task. After this task JavaScript is being
> called.
> > >
> > > I've put the code into render renderHead() method of the step itself:
> > >
> > > @Override
> > > public void renderHead(IHeaderResponse response) {
> > >     // process task
> > >     String taskResult = ...
> > >     // call JavaScript with result
> > >     response.render(OnDomReadyHeaderItem.forScript("jsFunction(" +
> > > taskResult + ")"));
> > > }
> > >
> > > When I click the NEXT button, this long running task is executed before
> > > the step with loading image is rendered.
> > > I guess I need to move the code somewhere else than renderHead() but
> > where?
> > >
> > > Thanks,
> > > Zbynek
> > >
> >
>

Re: Paint UI before starting long running task

Posted by Zbynek Vavros <zb...@gmail.com>.
I could use onAfterRender() but I can't call JS from that.

On Wed, May 30, 2018 at 5:00 PM, Zbynek Vavros <zb...@gmail.com>
wrote:

> Hey,
>
> this is weird, I can see the Ajax loading during renderHead() processing
> and then switch to my loading.
>
> Maybe I could describe what I'm doing in more details (with
> AjaxLazyLoadPanel  being used):
> Loader from AjaxLazyLoadPanel is displayed.
> Remote REST is being called, response from REST is passed to JS function -
> at this moment my panel is rendered.
> JS then calls remote service via websocket, receives response, passed that
> response to Wicket JS callback function.
> This calls yet another REST endpoint and saves result into DB.
>
> After that I replace my loading with success message.
>
> I would like to "ideally" have all this covered by single loading panel.
>
> Zbynek
>
>
> On Wed, May 30, 2018 at 3:32 PM, Martin Grigorov <mg...@apache.org>
> wrote:
>
>> Hi,
>>
>> Do you use AjaxLazyLoadPanel for the loading image + result panel ?
>> You can move your #renderHead() logic to the result panel's renderHead().
>>
>> On Wed, May 30, 2018 at 3:05 PM, Zbynek Vavros <zb...@gmail.com>
>> wrote:
>>
>> > Hi,
>> >
>> > I got a wizard and one of its steps display loading image while
>> > processing long running task. After this task JavaScript is being
>> called.
>> >
>> > I've put the code into render renderHead() method of the step itself:
>> >
>> > @Override
>> > public void renderHead(IHeaderResponse response) {
>> >     // process task
>> >     String taskResult = ...
>> >     // call JavaScript with result
>> >     response.render(OnDomReadyHeaderItem.forScript("jsFunction(" +
>> > taskResult + ")"));
>> > }
>> >
>> > When I click the NEXT button, this long running task is executed before
>> > the step with loading image is rendered.
>> > I guess I need to move the code somewhere else than renderHead() but
>> where?
>> >
>> > Thanks,
>> > Zbynek
>> >
>>
>
>

Re: Paint UI before starting long running task

Posted by Zbynek Vavros <zb...@gmail.com>.
Hey,

this is weird, I can see the Ajax loading during renderHead() processing
and then switch to my loading.

Maybe I could describe what I'm doing in more details (with
AjaxLazyLoadPanel  being used):
Loader from AjaxLazyLoadPanel is displayed.
Remote REST is being called, response from REST is passed to JS function -
at this moment my panel is rendered.
JS then calls remote service via websocket, receives response, passed that
response to Wicket JS callback function.
This calls yet another REST endpoint and saves result into DB.

After that I replace my loading with success message.

I would like to "ideally" have all this covered by single loading panel.

Zbynek


On Wed, May 30, 2018 at 3:32 PM, Martin Grigorov <mg...@apache.org>
wrote:

> Hi,
>
> Do you use AjaxLazyLoadPanel for the loading image + result panel ?
> You can move your #renderHead() logic to the result panel's renderHead().
>
> On Wed, May 30, 2018 at 3:05 PM, Zbynek Vavros <zb...@gmail.com>
> wrote:
>
> > Hi,
> >
> > I got a wizard and one of its steps display loading image while
> > processing long running task. After this task JavaScript is being called.
> >
> > I've put the code into render renderHead() method of the step itself:
> >
> > @Override
> > public void renderHead(IHeaderResponse response) {
> >     // process task
> >     String taskResult = ...
> >     // call JavaScript with result
> >     response.render(OnDomReadyHeaderItem.forScript("jsFunction(" +
> > taskResult + ")"));
> > }
> >
> > When I click the NEXT button, this long running task is executed before
> > the step with loading image is rendered.
> > I guess I need to move the code somewhere else than renderHead() but
> where?
> >
> > Thanks,
> > Zbynek
> >
>

Re: Paint UI before starting long running task

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Do you use AjaxLazyLoadPanel for the loading image + result panel ?
You can move your #renderHead() logic to the result panel's renderHead().

On Wed, May 30, 2018 at 3:05 PM, Zbynek Vavros <zb...@gmail.com>
wrote:

> Hi,
>
> I got a wizard and one of its steps display loading image while
> processing long running task. After this task JavaScript is being called.
>
> I've put the code into render renderHead() method of the step itself:
>
> @Override
> public void renderHead(IHeaderResponse response) {
>     // process task
>     String taskResult = ...
>     // call JavaScript with result
>     response.render(OnDomReadyHeaderItem.forScript("jsFunction(" +
> taskResult + ")"));
> }
>
> When I click the NEXT button, this long running task is executed before
> the step with loading image is rendered.
> I guess I need to move the code somewhere else than renderHead() but where?
>
> Thanks,
> Zbynek
>