Re: AjaxSelfUpdatingBehaviour detaches my DataTable

2018-11-14 Thread Sven Meier

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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



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



Re: AjaxSelfUpdatingBehaviour detaches my DataTable

2018-11-14 Thread 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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: LambdaModel use

2018-11-14 Thread Bas Gooren
Hi!


Well, that’s a different use-case :-)


We have written a specialized ConversionModel for the exact same reason:
convert an underlying model to a target type.

And of course a specialization of that called LambdaConversionModel, which
also allows conversion of null values.

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 11 november 2018 bij 00:42:38, Илья Нарыжный (phan...@ydn.ru) schreef:

Thank you, Bas!
Fully agree with you that if setters is to set something on a main target
object. In my particular case, I tried to use LambdaModel for "conversion"
between one type and another. So targetModel contain original object and
LambdaModel just wrap and convert correspondingly. Also I tried to use
exactly that method, because if targetModel is provided to LambdaModel - it
manages lifecycle and invoke onDetach when it's applicable. Use of `public
static  IModel of(SerializableSupplier getter,
SerializableConsumer setter)` is not so convenient in this case, because
target model is out of required lifecycle.

Thanks,
Ilia

-
Orienteer(http://orienteer.org) - open source Business Application Platform

On Thu, Nov 8, 2018 at 11:41 PM Bas Gooren  wrote:

> Hi,
>
> The LambdaModel method you are referring to is dependant on another model:
>
> public static  IModel of(IModel target,
> SerializableFunction getter, SerializableBiConsumer setter)
>
> Since the setter depends on the target model, the target model object
> needs to be non-null for the setter to be able to do anything (you can’t
> set a property on a null object reference).
>
> If I look at the current master branch [1], I see that the functionality
> you probably are looking for is present:
>
> public static  IModel of(SerializableSupplier getter,
> SerializableConsumer setter)
>
> … which is simply a model which delegates getting and setting the value to
> the specified supplier and consumer, without having a target model.
>
> 1)
> https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/model/LambdaModel.java
>
> Met vriendelijke groet,
> Kind regards,
>
> Bas Gooren
>
> Op 9 november 2018 bij 08:30:39, Илья Нарыжный (phan...@ydn.ru) schreef:
>
> Hello,
>
> How it was expected to use LambdaModel with setters?
> Right now it seems to be not quite usable, because, of the following code
> inside:
>
> @Override
> public void setObject(R r)
> {
> X x = target.getObject();
> if (x != null)
> {
> setter.accept(x, r);
> }
> }
>
> As you can see, if previous value of target model is null, there is no way
> to change it. Why?
> And also it will be interesting to know why SerializableBiConsumer was used
> for a setter?
>
> Thanks,
> Ilia
>
> -
> Orienteer(http://orienteer.org) - open source Business Application
> Platform
>
>


Re: AjaxSelfUpdatingBehaviour detaches my DataTable

2018-11-14 Thread Bas Gooren
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 (sfe...@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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org