You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Sandor Feher <sf...@bluesystem.hu> on 2018/11/12 13:12:42 UTC

Re: AjaxSelfUpdatingBehaviour detaches my DataTable

Hi,

I feel a little bit dump but I can't fix it. 

At the moment it looks like if I want my DataTable get reloaded then I must
call explicitly a public method in my DataProvider. 

So far I simply called detachModel() on my DataTable and in detach method I
reloaded list using my DAO.
Because of AwareAjaxSelfUpdatingBehaviour (which is in my HeaderPanel which
is included by BasePage and every page classes extend the BasePage) all
pages get detached in every second.

TIA, Sandor

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

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


Re: AjaxSelfUpdatingBehaviour detaches my DataTable

Posted by sven <sv...@meiers.net>.
 
 
Hi,  
 

 
If your queries are so expensive you can just keep its results as a member in your component. Make a new query each time a filter changes, and let your dataProvider just iterate over the cached list.
 

 
Note that your Data gets serialized with your page though.
 

 
Sven
 
 
 

 
 
 
 
 
>  
> On 19.11.2018 at 12:00,  <Sandor Feher>  wrote:
>  
>  
>  Hi Sven, Sorry, I did not notice your answer so far. Okay. Let's try to see things from different angle :) Yes I use spring. I tried to reduce the number of unnecessary queries. To achieve this I try to catch if my table filtered or a new item added or a dropdownchoice changed and so on. It works more or less but there is no method to catch an ajax table refresh for example (Catching it in detach() method is bad practice you made me sure) Here is a simple DataProvider I use. The question is that which point should I reload data using customBo? At size() or Iterator ? What is the best practice for this ? -- Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org For additional commands, e-mail: users-help@wicket.apache.org 
>  
     

Re: AjaxSelfUpdatingBehaviour detaches my DataTable

Posted by Sandor Feher <sf...@bluesystem.hu>.
Hi Sven,

Sorry, I did not notice your answer so far.
Okay. Let's try to  see things from different angle :)

Yes I use spring. I tried to reduce the number of unnecessary queries. To
achieve this I try to catch if my table filtered or a new item added or a
dropdownchoice changed and so on.

It works more or less but there is no method to catch an ajax table refresh
for example (Catching it in detach() method is bad practice you made me
sure)

Here is a simple DataProvider I use.  The question is that which point
should I reload data using customBo?

At size() or Iterator ?  What is the best practice for this ?







--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

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


Re: AjaxSelfUpdatingBehaviour detaches my DataTable

Posted by Sven Meier <sv...@meiers.net>.
Hi Sandor,

why doesn't your myDAO 'detach'(=clear) its cache automatically whenever 
a new item is added?

Wicket might call #detach() in a lot of circumstances, thus this has to 
be a very quick operation.

It's better to avoid tying your caching to your UI layer. If you're 
using Spring, you can add caching to your service via annotations quite 
easily:

https://docs.spring.io/spring/docs/4.0.x/spring-framework-reference/html/cache.html

Have fun
Sven


Am 14.11.18 um 22:38 schrieb Sandor Feher:
> Hi,
>
> Sorry for the confusing.
> Let me explain it more.
> Let's suppose a simple CRUD page with a single DataTable and it's
> dataprovider.
> I need to refresh my datatable after a new item added.
>
> So far I did it like this:
>
> mw = new ModalWindow("modal");
> mw.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
>                  private static final long serialVersionUID = 1L;
>
>                  @Override
>                  public void onClose(AjaxRequestTarget target) {
>                      dataTable.detachModels();
>                      target.add(wm_bottom);
>                  }
>              });
>
> In my dataprovider I reloaded data when datatable (and dataprovider) got
> detached.
>
>      @Override
>      public void detach() {
>            myDAO.refreshData();
>      }
>
> and every other cases when datatable filtered or cleared and so one.
> And at this point AjaxSelfupdatingBehaviour comes in the picture. I can't
> rely on ondetach method anymore because it's fired in every second not just
> when it needed.
>
> I hope I need a different approach to refresh my data but I did not figure
> it out so far.
>
> Regards,  Sandor
>
> --
> Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

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


Re: AjaxSelfUpdatingBehaviour detaches my DataTable

Posted by Sandor Feher <sf...@bluesystem.hu>.
Hi,

Sorry for the confusing.
Let me explain it more.
Let's suppose a simple CRUD page with a single DataTable and it's
dataprovider.
I need to refresh my datatable after a new item added.

So far I did it like this:

mw = new ModalWindow("modal");
mw.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClose(AjaxRequestTarget target) {
                    dataTable.detachModels();
                    target.add(wm_bottom);
                }
            });

In my dataprovider I reloaded data when datatable (and dataprovider) got
detached.

    @Override
    public void detach() {
          myDAO.refreshData();
    }

and every other cases when datatable filtered or cleared and so one.
And at this point AjaxSelfupdatingBehaviour comes in the picture. I can't
rely on ondetach method anymore because it's fired in every second not just
when it needed.

I hope I need a different approach to refresh my data but I did not figure
it out so far.

Regards,  Sandor 

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

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


Re: AjaxSelfUpdatingBehaviour detaches my DataTable

Posted by Bas Gooren <ba...@iswd.nl>.
Hi Sandor,

Can you explain more clearly (step by step, request by request) what is
happening and what you expect to happen?

Most dataproviders (e.g. ones backed by a database model) reload their
underlying data on every request, so reloading should be easy (simply add
the datatable to the ajax request or reload the entire page).
What kind of data provider are you using?

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 12 november 2018 bij 14:19:09, Sandor Feher (sfeher@bluesystem.hu)
schreef:

Hi,

I feel a little bit dump but I can't fix it.

At the moment it looks like if I want my DataTable get reloaded then I must
call explicitly a public method in my DataProvider.

So far I simply called detachModel() on my DataTable and in detach method I
reloaded list using my DAO.
Because of AwareAjaxSelfUpdatingBehaviour (which is in my HeaderPanel which
is included by BasePage and every page classes extend the BasePage) all
pages get detached in every second.

TIA, Sandor

-- 
Sent from:
http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

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