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
> > <http://mailto: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:
> > > >>>>>
> > > >>>>> 

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
<http://mailto: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", " ");
> >>>>>
&

Getting the model

2016-03-31 Thread Ron Smits
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"));
}

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 cannot find a way to
access the model.

What am I missing?

Ron
​


Re: JPA annotations

2012-12-23 Thread Ron Smits
check http://jeff-schwartz.blogspot.nl/2011/03/java-ee6-wicket.html its a
good series of articles about using Java EE and wicket

I Haven't Lost My Mind - It's Backed Up On Disk Somewhere


On Fri, Dec 21, 2012 at 1:30 PM, Lucio Crusca  wrote:

> Hello *,
>
> I've started this short thread on the tomEE users ml:
>
> http://markmail.org/message/3asqvvptnkieknq5
>
> The final answer sounds to me like "if you want to use resources injection
> through JPA annotations in a wicket application, your best bet is Java-EE-
> Inject"
>
> https://github.com/wicketstuff/core/wiki/Java-EE-Inject
>
> which in turn states that:
>
> "With JavaEE Inject you can use in your wicket components three
> annotations:
> @EJB, @PersistenceUnit, @Resource".
>
> What about @Entity, @Table, @Id, @GeneratedValue and friends?
>
> What's the simplest way to use JPA annotations and dependency injection
> threreof in a wicket application?
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: confusion in selecting guice and spring for Ioc

2011-07-10 Thread Ron Smits
Mixing guice and Spring will alwyas conflict. You have to chose one DI
container and make it work in that. Both are quite easy to set up and use.
Spring is more mature then guice, But Guice is cleaner :)

Ron
I Haven't Lost My Mind - It's Backed Up On Disk Somewhere


On Sun, Jul 10, 2011 at 01:47, hariharansrc  wrote:

> I need to integrate jasper reports and hibernate for my project. I got
> archetype for hibernate. And I choose wicket-guice-warp-persist-hibernate.
> Then for jasper reports when I search I am getting archetypes but i am
> getting archetypes using spring. So it results learning both of them. So,
> anybody recommend what to do. Just go with this configuration or any
> problem
> or conflict will occur from this. Just tell if it costs conflicts.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/confusion-in-selecting-guice-and-spring-for-Ioc-tp3656982p3656982.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>