Re: Getting the model

2016-04-06 Thread Ron Smits
You were right, fixed it

On Wed, Apr 6, 2016 at 6:49 PM Martin Grigorov  wrote:

> Please read the answers.
> On Apr 6, 2016 7:26 PM, "Ron Smits"  wrote:
>
> > This alas does not work:(
> >
> > First I am using wicket 7.2.0 and the getModelObject does not exist so I
> > finally made:
> >
> > @Override
> > protected void onComponentTag(ComponentTag tag) {
> > add(new AttributeAppender("class", " number"));
> > if(getDefaultModel().getObject() instanceof Number){
> > Number number = (Number) getDefaultModelObject();
> > if(number.doubleValue()<0.0)
> > add(new AttributeAppender("class", " negative"));
> >}
> > }
> >
> > This however gives the following exception:
> >
> > org.apache.wicket.WicketRuntimeException: Cannot modify component
> > hierarchy after render phase has started (page version cant change
> > then anymore)
> >  at
> > org.apache.wicket.Component.checkHierarchyChange(Component.java:3623)
> >  at org.apache.wicket.Component.addStateChange(Component.java:3538)
> >  at org.apache.wicket.Behaviors.add(Behaviors.java:55)
> >  at org.apache.wicket.Component.add(Component.java:4559)
> >  at
> >
> nl.codetribe.budget.web.common.MoneyLabel.onComponentTag(MoneyLabel.java:36)
> >  at
> > org.apache.wicket.Component.internalRenderComponent(Component.java:2521)
> >
> > On Fri, Apr 1, 2016 at 3:11 PM Tobias Soloschenko
> > tobiassolosche...@googlemail.com
> >  wrote:
> >
> > Cool - thanks!
> > >
> > > kind regards
> > >
> > > Tobias
> > >
> > > > Am 01.04.2016 um 14:56 schrieb Martin Grigorov  >:
> > > >
> > > > I've added an example with
> > > >
> > >
> >
> https://github.com/apache/wicket/commit/2417322673238d57a794c237e84dd5dacf890804
> > > >
> > > > I think we should explain that those are just convenience. It is
> better
> > > to
> > > > use the "old way" one cares about memory usage. I'll add it soon.
> > > >
> > > > Martin Grigorov
> > > > Wicket Training and Consulting
> > > > https://twitter.com/mtgrigorov
> > > >
> > > > On Fri, Apr 1, 2016 at 2:48 PM, Tobias Soloschenko <
> > > > tobiassolosche...@googlemail.com> wrote:
> > > >
> > > >> Hi,
> > > >>
> > > >> would be great to see some information how to use lambda models in
> the
> > > >> user guide.
> > > >>
> > > >> kind regards
> > > >>
> > > >> Tobias
> > > >>
> > >  Am 01.04.2016 um 13:57 schrieb Martin Grigorov <
> > mgrigo...@apache.org
> > > >:
> > > 
> > >  On Fri, Apr 1, 2016 at 12:45 AM, Sven Meier 
> > wrote:
> > > 
> > >  Hi,
> > > 
> > >  yeah, of course this is right:
> > > 
> > >    protected void onComponentTag(final ComponentTag tag) {
> > > 
> > >    if (getModelObject().doubleValue() < 0.0) {
> > >    tag.put("class", " negative");
> > >    }
> > >    }
> > > 
> > >  Otherwise you'll end up with one additional behavior for each
> > render -
> > >  stupid copy-paste error :/.
> > > 
> > >  BTW this might be an additional candidate for the new Wicket 8
> > > lambdas:
> > > 
> > >    label.add(onTag(tag -> if (getModelObject().doubleValue() < 0.0)
> > >  tag.put("class", "negative") ));
> > > >>>
> > > >>> +1
> > > >>>
> > > >>
> > > >> +1
> > > >>
> > > >>>
> > > 
> > >  Sven
> > > 
> > > 
> > > 
> > > > On 31.03.2016 21:16, Martin Grigorov wrote:
> > > >
> > > > Hi,
> > > >
> > > > On Thu, Mar 31, 2016 at 4:29 PM, Sven Meier 
> > wrote:
> > > >
> > > > Hi,
> > > >>
> > > >> you can access a component's model with #getDefaultModel() or -
> if
> > > it
> > > >> is
> > > >> a
> > > >> generic component - with #getModel().
> > > >>
> > > >> To properly 'bind' to a model you should delay invocation of
> > > >> #getObject()
> > > >> as late as possible, so better overwrite #onComponentTag():
> > > >>
> > > >>protected void onComponentTag(final ComponentTag tag) {
> > > >>
> > > >>if (getModelObject().doubleValue() < 0.0) {
> > > >>add(new AttributeAppender("class", " negative"));
> > > >>
> > > >> Since you are in #onComponentTag() there is no reason to add a
> > > >> Behavior.
> > > > Just use the tag: tag.append("class", "negative", " ");
> > > >
> > > >
> > > >}
> > > >>}
> > > >>
> > > >>
> > > >> Have fun
> > > >> Sven
> > > >>
> > > >>
> > > >>
> > > >>
> > > >> On 31.03.2016 16:06, Ron Smits wrote:
> > > >>
> > > >> I have searched but I dont find a clear way of getting the model
> > > when
> > > >> one
> > > >>> is creating a custom component:
> > > >>>
> > > >>>
> > > >>> public MoneyLabel(String id) {
> > > >>> super(id);
> > > >>> add(new AttributeAppender("class", " number"));
> > > 

Re: Getting the model

2016-04-06 Thread Martin Grigorov
Please read the answers.
On Apr 6, 2016 7:26 PM, "Ron Smits"  wrote:

> This alas does not work:(
>
> First I am using wicket 7.2.0 and the getModelObject does not exist so I
> finally made:
>
> @Override
> protected void onComponentTag(ComponentTag tag) {
> add(new AttributeAppender("class", " number"));
> if(getDefaultModel().getObject() instanceof Number){
> Number number = (Number) getDefaultModelObject();
> if(number.doubleValue()<0.0)
> add(new AttributeAppender("class", " negative"));
>}
> }
>
> This however gives the following exception:
>
> org.apache.wicket.WicketRuntimeException: Cannot modify component
> hierarchy after render phase has started (page version cant change
> then anymore)
>  at
> org.apache.wicket.Component.checkHierarchyChange(Component.java:3623)
>  at org.apache.wicket.Component.addStateChange(Component.java:3538)
>  at org.apache.wicket.Behaviors.add(Behaviors.java:55)
>  at org.apache.wicket.Component.add(Component.java:4559)
>  at
> nl.codetribe.budget.web.common.MoneyLabel.onComponentTag(MoneyLabel.java:36)
>  at
> org.apache.wicket.Component.internalRenderComponent(Component.java:2521)
>
> On Fri, Apr 1, 2016 at 3:11 PM Tobias Soloschenko
> tobiassolosche...@googlemail.com
>  wrote:
>
> Cool - thanks!
> >
> > kind regards
> >
> > Tobias
> >
> > > Am 01.04.2016 um 14:56 schrieb Martin Grigorov :
> > >
> > > I've added an example with
> > >
> >
> https://github.com/apache/wicket/commit/2417322673238d57a794c237e84dd5dacf890804
> > >
> > > I think we should explain that those are just convenience. It is better
> > to
> > > use the "old way" one cares about memory usage. I'll add it soon.
> > >
> > > Martin Grigorov
> > > Wicket Training and Consulting
> > > https://twitter.com/mtgrigorov
> > >
> > > On Fri, Apr 1, 2016 at 2:48 PM, Tobias Soloschenko <
> > > tobiassolosche...@googlemail.com> wrote:
> > >
> > >> Hi,
> > >>
> > >> would be great to see some information how to use lambda models in the
> > >> user guide.
> > >>
> > >> kind regards
> > >>
> > >> Tobias
> > >>
> >  Am 01.04.2016 um 13:57 schrieb Martin Grigorov <
> mgrigo...@apache.org
> > >:
> > 
> >  On Fri, Apr 1, 2016 at 12:45 AM, Sven Meier 
> wrote:
> > 
> >  Hi,
> > 
> >  yeah, of course this is right:
> > 
> >    protected void onComponentTag(final ComponentTag tag) {
> > 
> >    if (getModelObject().doubleValue() < 0.0) {
> >    tag.put("class", " negative");
> >    }
> >    }
> > 
> >  Otherwise you'll end up with one additional behavior for each
> render -
> >  stupid copy-paste error :/.
> > 
> >  BTW this might be an additional candidate for the new Wicket 8
> > lambdas:
> > 
> >    label.add(onTag(tag -> if (getModelObject().doubleValue() < 0.0)
> >  tag.put("class", "negative") ));
> > >>>
> > >>> +1
> > >>>
> > >>
> > >> +1
> > >>
> > >>>
> > 
> >  Sven
> > 
> > 
> > 
> > > On 31.03.2016 21:16, Martin Grigorov wrote:
> > >
> > > Hi,
> > >
> > > On Thu, Mar 31, 2016 at 4:29 PM, Sven Meier 
> wrote:
> > >
> > > Hi,
> > >>
> > >> you can access a component's model with #getDefaultModel() or - if
> > it
> > >> is
> > >> a
> > >> generic component - with #getModel().
> > >>
> > >> To properly 'bind' to a model you should delay invocation of
> > >> #getObject()
> > >> as late as possible, so better overwrite #onComponentTag():
> > >>
> > >>protected void onComponentTag(final ComponentTag tag) {
> > >>
> > >>if (getModelObject().doubleValue() < 0.0) {
> > >>add(new AttributeAppender("class", " negative"));
> > >>
> > >> Since you are in #onComponentTag() there is no reason to add a
> > >> Behavior.
> > > Just use the tag: tag.append("class", "negative", " ");
> > >
> > >
> > >}
> > >>}
> > >>
> > >>
> > >> Have fun
> > >> Sven
> > >>
> > >>
> > >>
> > >>
> > >> On 31.03.2016 16:06, Ron Smits wrote:
> > >>
> > >> I have searched but I dont find a clear way of getting the model
> > when
> > >> one
> > >>> is creating a custom component:
> > >>>
> > >>>
> > >>> public MoneyLabel(String id) {
> > >>> super(id);
> > >>> add(new AttributeAppender("class", " number"));
> > >>> }
> > >>>
> > >>> It sounds like you always need the model.
> > > If there is a CompoundPropertyModel in the parents' hierarchy then
> > move
> > > your logic to #onComponentTag(), as per Sven's suggestion.
> > > If there is no CPM in the parents then just remove this
> constructor.
> > >
> > >
> > > public MoneyLabel(String id, Model
> > >> bigDecimalModel)
> > >>> {
> > >>> 

Re: Getting the model

2016-04-06 Thread Ron Smits
This alas does not work:(

First I am using wicket 7.2.0 and the getModelObject does not exist so I
finally made:

@Override
protected void onComponentTag(ComponentTag tag) {
add(new AttributeAppender("class", " number"));
if(getDefaultModel().getObject() instanceof Number){
Number number = (Number) getDefaultModelObject();
if(number.doubleValue()<0.0)
add(new AttributeAppender("class", " negative"));
   }
}

This however gives the following exception:

org.apache.wicket.WicketRuntimeException: Cannot modify component
hierarchy after render phase has started (page version cant change
then anymore)
 at org.apache.wicket.Component.checkHierarchyChange(Component.java:3623)
 at org.apache.wicket.Component.addStateChange(Component.java:3538)
 at org.apache.wicket.Behaviors.add(Behaviors.java:55)
 at org.apache.wicket.Component.add(Component.java:4559)
 at 
nl.codetribe.budget.web.common.MoneyLabel.onComponentTag(MoneyLabel.java:36)
 at org.apache.wicket.Component.internalRenderComponent(Component.java:2521)

On Fri, Apr 1, 2016 at 3:11 PM Tobias Soloschenko
tobiassolosche...@googlemail.com
 wrote:

Cool - thanks!
>
> kind regards
>
> Tobias
>
> > Am 01.04.2016 um 14:56 schrieb Martin Grigorov :
> >
> > I've added an example with
> >
> https://github.com/apache/wicket/commit/2417322673238d57a794c237e84dd5dacf890804
> >
> > I think we should explain that those are just convenience. It is better
> to
> > use the "old way" one cares about memory usage. I'll add it soon.
> >
> > Martin Grigorov
> > Wicket Training and Consulting
> > https://twitter.com/mtgrigorov
> >
> > On Fri, Apr 1, 2016 at 2:48 PM, Tobias Soloschenko <
> > tobiassolosche...@googlemail.com> wrote:
> >
> >> Hi,
> >>
> >> would be great to see some information how to use lambda models in the
> >> user guide.
> >>
> >> kind regards
> >>
> >> Tobias
> >>
>  Am 01.04.2016 um 13:57 schrieb Martin Grigorov  >:
> 
>  On Fri, Apr 1, 2016 at 12:45 AM, Sven Meier  wrote:
> 
>  Hi,
> 
>  yeah, of course this is right:
> 
>    protected void onComponentTag(final ComponentTag tag) {
> 
>    if (getModelObject().doubleValue() < 0.0) {
>    tag.put("class", " negative");
>    }
>    }
> 
>  Otherwise you'll end up with one additional behavior for each render -
>  stupid copy-paste error :/.
> 
>  BTW this might be an additional candidate for the new Wicket 8
> lambdas:
> 
>    label.add(onTag(tag -> if (getModelObject().doubleValue() < 0.0)
>  tag.put("class", "negative") ));
> >>>
> >>> +1
> >>>
> >>
> >> +1
> >>
> >>>
> 
>  Sven
> 
> 
> 
> > On 31.03.2016 21:16, Martin Grigorov wrote:
> >
> > Hi,
> >
> > On Thu, Mar 31, 2016 at 4:29 PM, Sven Meier  wrote:
> >
> > Hi,
> >>
> >> you can access a component's model with #getDefaultModel() or - if
> it
> >> is
> >> a
> >> generic component - with #getModel().
> >>
> >> To properly 'bind' to a model you should delay invocation of
> >> #getObject()
> >> as late as possible, so better overwrite #onComponentTag():
> >>
> >>protected void onComponentTag(final ComponentTag tag) {
> >>
> >>if (getModelObject().doubleValue() < 0.0) {
> >>add(new AttributeAppender("class", " negative"));
> >>
> >> Since you are in #onComponentTag() there is no reason to add a
> >> Behavior.
> > Just use the tag: tag.append("class", "negative", " ");
> >
> >
> >}
> >>}
> >>
> >>
> >> Have fun
> >> Sven
> >>
> >>
> >>
> >>
> >> On 31.03.2016 16:06, Ron Smits wrote:
> >>
> >> I have searched but I dont find a clear way of getting the model
> when
> >> one
> >>> is creating a custom component:
> >>>
> >>>
> >>> public MoneyLabel(String id) {
> >>> super(id);
> >>> add(new AttributeAppender("class", " number"));
> >>> }
> >>>
> >>> It sounds like you always need the model.
> > If there is a CompoundPropertyModel in the parents' hierarchy then
> move
> > your logic to #onComponentTag(), as per Sven's suggestion.
> > If there is no CPM in the parents then just remove this constructor.
> >
> >
> > public MoneyLabel(String id, Model
> >> bigDecimalModel)
> >>> {
> >>> super(id, bigDecimalModel);
> >>> add(new AttributeAppender("class", " number"));
> >>> if (bigDecimalModel.getObject().doubleValue() < 0.0) {
> >>> add(new AttributeAppender("class", " negative"));
> >>> }
> >>> }
> >>>
> >>> In the second constructor I can use the supplied model to determine
> >> to
> >>> add
> >>> the negative class. However in the first constructor I 

Re: Correct way to clear disk cache and session data?

2016-04-06 Thread Matt Pavlovich

Thanks!

On 4/6/16 12:42 AM, Martin Grigorov wrote:

Hi,

On Apr 5, 2016 9:53 PM, "Matt Pavlovich"  wrote:

Ahead of performing an upgrade, we would like to clear all sessions and

disk cache to avoid any serialization issues with new version of code.

Googling around, I find a number of different approaches, but haven't

seen anything consistent or definitive.

Is there an API built into Wicket to perform this task?

No.


Is deleting the files on-disk too heavy-handed?

It should be fine.


Thanks,
Matt

-
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