Re: [wicket 6] Create/Register Spring Bean in wicket ?

2013-05-13 Thread smallufo
I solve this problem by introducing another spring's xml inside wicket's
repository, which I didn't want to do this at first.
(I was looking for a programmatic way , but it seems not so easy... )



2013/5/11 smallufo 

>
>
>
> 2013/5/11 Marco Springer 
>
>> Maybe this is too simple but:
>>
>> Did you define this bean in the applicationContext.xml?:
>>   {possible properties}
>>
>>
>
> No this is not what I want.
>
> The whole story is ...
> I have two maven repositories :
>
> One is *business-layer* , which defines whole business objects , service
> layers , and make use of SpringConfig and package scan to build a lot of
> beans .
> Another is *wicket-layer* , which depends on business-layer , and makes
> use of beans scanned in the business-layer and serve the web.
>
> The problem is :
> All the beans are defined ( package scanned ) in the business-layer.
> There is no spring's xml or spring's @Repository class or SpringConfig
> settings in the wicket-layer.
>
> But I have some idea of implementing some interface which depends on
> wicket's library.
> Such as getting absolute url of a DynamicImageReference or a
> PackageResourceReference
>  , which depends on RequestCycle and wicket's components.
>
> I wonder how to programmatically generate such bean and inject to the
> spring ?
>
> class MyApplication extends WebApplication {
>   @SpringBean dao;  // defined in business-layer , and injected
> successfully.
>
>   public init () {
> getComponentInstantiationListeners().add(new
> SpringComponentInjector(this));
> Injector.get().inject(this);
>
> *URLGetter urlGetter = new URLGetterDynImgRefImpl(dao);*
> // How to inject this "urlGetter" to spring ?
>   }
> }
>
> In the above code , how to inject the "urlGetter" object to Spring ? so
> that other wicket WebPage or Panel can use @SpringBean(name="urlGetter") to
> get the object ?
>
> Thanks.
>
>


Re: [wicket 6] Create/Register Spring Bean in wicket ?

2013-05-11 Thread smallufo
2013/5/11 Marco Springer 

> Maybe this is too simple but:
>
> Did you define this bean in the applicationContext.xml?:
>   {possible properties}
>
>

No this is not what I want.

The whole story is ...
I have two maven repositories :

One is *business-layer* , which defines whole business objects , service
layers , and make use of SpringConfig and package scan to build a lot of
beans .
Another is *wicket-layer* , which depends on business-layer , and makes use
of beans scanned in the business-layer and serve the web.

The problem is :
All the beans are defined ( package scanned ) in the business-layer.
There is no spring's xml or spring's @Repository class or SpringConfig
settings in the wicket-layer.

But I have some idea of implementing some interface which depends on
wicket's library.
Such as getting absolute url of a DynamicImageReference or a
PackageResourceReference
 , which depends on RequestCycle and wicket's components.

I wonder how to programmatically generate such bean and inject to the
spring ?

class MyApplication extends WebApplication {
  @SpringBean dao;  // defined in business-layer , and injected
successfully.

  public init () {
getComponentInstantiationListeners().add(new
SpringComponentInjector(this));
Injector.get().inject(this);

*URLGetter urlGetter = new URLGetterDynImgRefImpl(dao);*
// How to inject this "urlGetter" to spring ?
  }
}

In the above code , how to inject the "urlGetter" object to Spring ? so
that other wicket WebPage or Panel can use @SpringBean(name="urlGetter") to
get the object ?

Thanks.


Re: [wicket 6] Create/Register Spring Bean in wicket ?

2013-05-10 Thread Marco Springer
Maybe this is too simple but:

Did you define this bean in the applicationContext.xml?:
  {possible properties}

And usually when I'm dealing with are objects that aren't wicket components, 
like models or the WebApplication object itself, I have to inject them.
In a WebApplication Object:
getComponentInstantiationListeners().add(new SpringComponentInjector(this));

In a model:
Injector.get().inject(this);

Cheers,
Marco

On Saturday 11 May 2013 11:21:38 smallufo wrote:
> I try to do this in init() :
> 
> ctx.getAutowireCapableBeanFactory().configureBean(obj, "myobj");
> or
> ctx.getAutowireCapableBeanFactory().applyBeanPostProcessorsAfterInitializati
> on(obj, "myobj");
> or
> ctx.getAutowireCapableBeanFactory().applyBeanPostProcessorsBeforeInitializat
> ion(obj, "myobj");
> 
> But in a WebPage with a @SpringBean(name="myobj") private IMyObj myobj;
> I still get NoSuchBeanDefinitionException error ...
> 
> 
> 
> 2013/5/11 smallufo 
> 
> > Hi
> > Is there any code example to create beans and register to spring ?
> > I can get ApplicationContext
> > by
> > WebApplicationContextUtils.getRequiredWebApplicationContext(getServletCon
> > text()); but there is no setter or register or createBean methods
> > within...
> > 
> > Or use of factory bean ?
> > I searched FactoryBean , got the idea behind it . But I still don't know
> > how to do it in wicket ?
> > 
> > Thanks.
> > 
> > 
> > 2013/5/11 Igor Vaynberg 
> > 
> >> see spring's FactoryBean, its an indirect way to create beans.
> >> 
> >> -igor
> >> 
> >> On Fri, May 10, 2013 at 12:33 PM, smallufo  wrote:
> >> > Hi , I wonder if it possible to programmatically create / register a
> >> 
> >> spring
> >> 
> >> > bean in wicket?
> >> > maybe in Application.init() ...
> >> > 
> >> > Most documents about spring are "making use of existent beans" , and
> >> 
> >> inject
> >> 
> >> > to WebPage or Panel via @SpringBean , and it indeed works well.
> >> > 
> >> > But my interface implementations are depend on wicket-component ,
> >> > such as getting absolute URL of a page or a DynamicImageResource
> >> > 
> >> > So these beans should be initialized and register to Spring in init()
> >> > (correct me if I am wrong)
> >> > 
> >> > Any way to achieve this ?
> >> > 
> >> > Thanks.
> >> > 
> >> > (I am using wicket 6.7 )
> >> 
> >> -
> >> 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: [wicket 6] Create/Register Spring Bean in wicket ?

2013-05-10 Thread smallufo
I try to do this in init() :

ctx.getAutowireCapableBeanFactory().configureBean(obj, "myobj");
or
ctx.getAutowireCapableBeanFactory().applyBeanPostProcessorsAfterInitialization(obj,
"myobj");
or
ctx.getAutowireCapableBeanFactory().applyBeanPostProcessorsBeforeInitialization(obj,
"myobj");

But in a WebPage with a @SpringBean(name="myobj") private IMyObj myobj;
I still get NoSuchBeanDefinitionException error ...



2013/5/11 smallufo 

> Hi
> Is there any code example to create beans and register to spring ?
> I can get ApplicationContext
> by 
> WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
> but there is no setter or register or createBean methods within...
>
> Or use of factory bean ?
> I searched FactoryBean , got the idea behind it . But I still don't know
> how to do it in wicket ?
>
> Thanks.
>
>
> 2013/5/11 Igor Vaynberg 
>
>> see spring's FactoryBean, its an indirect way to create beans.
>>
>> -igor
>>
>> On Fri, May 10, 2013 at 12:33 PM, smallufo  wrote:
>> > Hi , I wonder if it possible to programmatically create / register a
>> spring
>> > bean in wicket?
>> > maybe in Application.init() ...
>> >
>> > Most documents about spring are "making use of existent beans" , and
>> inject
>> > to WebPage or Panel via @SpringBean , and it indeed works well.
>> >
>> > But my interface implementations are depend on wicket-component ,
>> > such as getting absolute URL of a page or a DynamicImageResource
>> >
>> > So these beans should be initialized and register to Spring in init()
>> > (correct me if I am wrong)
>> >
>> > Any way to achieve this ?
>> >
>> > Thanks.
>> >
>> > (I am using wicket 6.7 )
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>


Re: [wicket 6] Create/Register Spring Bean in wicket ?

2013-05-10 Thread smallufo
Hi
Is there any code example to create beans and register to spring ?
I can get ApplicationContext
by 
WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
but there is no setter or register or createBean methods within...

Or use of factory bean ?
I searched FactoryBean , got the idea behind it . But I still don't know
how to do it in wicket ?

Thanks.


2013/5/11 Igor Vaynberg 

> see spring's FactoryBean, its an indirect way to create beans.
>
> -igor
>
> On Fri, May 10, 2013 at 12:33 PM, smallufo  wrote:
> > Hi , I wonder if it possible to programmatically create / register a
> spring
> > bean in wicket?
> > maybe in Application.init() ...
> >
> > Most documents about spring are "making use of existent beans" , and
> inject
> > to WebPage or Panel via @SpringBean , and it indeed works well.
> >
> > But my interface implementations are depend on wicket-component ,
> > such as getting absolute URL of a page or a DynamicImageResource
> >
> > So these beans should be initialized and register to Spring in init()
> > (correct me if I am wrong)
> >
> > Any way to achieve this ?
> >
> > Thanks.
> >
> > (I am using wicket 6.7 )
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: [wicket 6] Create/Register Spring Bean in wicket ?

2013-05-10 Thread Igor Vaynberg
see spring's FactoryBean, its an indirect way to create beans.

-igor

On Fri, May 10, 2013 at 12:33 PM, smallufo  wrote:
> Hi , I wonder if it possible to programmatically create / register a spring
> bean in wicket?
> maybe in Application.init() ...
>
> Most documents about spring are "making use of existent beans" , and inject
> to WebPage or Panel via @SpringBean , and it indeed works well.
>
> But my interface implementations are depend on wicket-component ,
> such as getting absolute URL of a page or a DynamicImageResource
>
> So these beans should be initialized and register to Spring in init()
> (correct me if I am wrong)
>
> Any way to achieve this ?
>
> Thanks.
>
> (I am using wicket 6.7 )

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



Re: [wicket 6] Create/Register Spring Bean in wicket ?

2013-05-10 Thread Richard W. Adams
Not sure exactly what the issue is. You can create beans any time you 
want. All you need to do is get an application context object based on a 
Spring config file. You can do that in init() or wherever is appropriate 
for your app.




From:   smallufo 
To: users@wicket.apache.org
Date:   05/10/2013 02:34 PM
Subject:[wicket 6] Create/Register Spring Bean in wicket ?



Hi , I wonder if it possible to programmatically create / register a 
spring
bean in wicket?
maybe in Application.init() ...

Most documents about spring are "making use of existent beans" , and 
inject
to WebPage or Panel via @SpringBean , and it indeed works well.

But my interface implementations are depend on wicket-component ,
such as getting absolute URL of a page or a DynamicImageResource

So these beans should be initialized and register to Spring in init()
(correct me if I am wrong)

Any way to achieve this ?

Thanks.

(I am using wicket 6.7 )



**

This email and any attachments may contain information that is confidential 
and/or privileged for the sole use of the intended recipient.  Any use, review, 
disclosure, copying, distribution or reliance by others, and any forwarding of 
this email or its contents, without the express permission of the sender is 
strictly prohibited by law.  If you are not the intended recipient, please 
contact the sender immediately, delete the e-mail and destroy all copies.
**