I'd be curious to hear for what "other classes" you have in mind. You'll
always need to call the instantiation listener at some point to invoke the
injector.
So simply implementing IInstantiable will not be enough to have injection
magically work.
I think the reason it's currently implemented the way it is, is that all
components have a Component base class which can abstract behavior like
this.
In case you want dependency injection anywhere, you should take a look at
something like Salve (http://code.google.com/p/salve/)
Sebastian
----- Original Message -----
From: "Ernesto Reinaldo Barreiro" <[email protected]>
To: <[email protected]>
Sent: Thursday, September 23, 2010 12:07 PM
Subject: Re: using IOC in panels?
Shall I create an RFE? Or this something that does not make much sense?
Ernesto
On Thu, Sep 23, 2010 at 11:51 AM, nino martinez wael
<[email protected]> wrote:
yeah that would be handy.
2010/9/23 Ernesto Reinaldo Barreiro <[email protected]>:
Martin,
Yes, I see:
getApplication().notifyComponentInstantiationListeners(this);
Would it make sense (for 1.5) to have:
-an interface IInstantiable
-modify
public interface IComponentInstantiationListener
{
/**
* Called for every component that is instantiated. This method is called
* <strong>during</strong> construction, so do not depend on the
construction being completed
* yet. The id is guaranteed to be set before this call.
*
* @param component
* the component that is being instantiated.
*/
void onInstantiation(IInstantiable component);
}
So that other classes could use the same trick by implementing
IInstantiable ?
Cheers,
Ernesto
On Thu, Sep 23, 2010 at 11:34 AM, Martin Grigorov <[email protected]>
wrote:
Panel's constructor calls super() and Component's ctor asks the
instantiation listener to do its work
On Thu, Sep 23, 2010 at 11:21 AM, Ernesto Reinaldo Barreiro <
[email protected]> wrote:
There is a component instantiation listener that takes care of that:
you just use new as "always".
Ernesto
On Thu, Sep 23, 2010 at 11:17 AM, nino martinez wael
<[email protected]> wrote:
> but how should panel then be managed..
>
> Because if I create the panel myself in the page it won't work right?
> Can I ask wicket to instansiate my panel?
>
> 2010/9/23 Martin Grigorov <[email protected]>:
>> Panel is a Component, so you can use @Inject on the Panel members.
>> Use Injector.get().inject(target) only in non Component classes.
>>
>> P.S. The API above is for 1.5.
>>
>> On Thu, Sep 23, 2010 at 11:03 AM, Martin Makundi <
>> [email protected]> wrote:
>>
>>> You must weigh benefits and cons about whereto manage your IOC.
>>>
>>> **
>>> Martin
>>>
>>> 2010/9/23 nino martinez wael <[email protected]>:
>>> > I need to be able to inject a service into my panel..
>>> >
>>> > Should I then just use:
>>> >
>>> > org.apache.wicket.injection.Injector.get().inject(Object object).
>>> >
>>> > or are there are prettier way? I feel that calling
>>> > org.apache.wicket.injection.Injector.get().inject(Object object)
>>> > inside my panels sort of violates the IOC principle?
>>> >
>>> > 2010/9/23 Martin Makundi <[email protected]>:
>>> >> What is your need exactly?
>>> >>
>>> >> **
>>> >> Martin
>>> >>
>>> >> 2010/9/23 nino martinez wael <[email protected]>:
>>> >>> Hi
>>> >>>
>>> >>> what should I do if I want to use IOC in my panels? In short I
>>> >>> need
a
>>> >>> sort of a provider injected into a panel, what's the prettiest
>>> >>> way
to
>>> >>> do it?
>>> >>>
>>> >>> regards Nino
>>> >>>
>>> >>>
---------------------------------------------------------------------
>>> >>> To unsubscribe, e-mail: [email protected]
>>> >>> For additional commands, e-mail: [email protected]
>>> >>>
>>> >>>
>>> >>
>>> >>
---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: [email protected]
>>> >> For additional commands, e-mail: [email protected]
>>> >>
>>> >>
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [email protected]
>>> > For additional commands, e-mail: [email protected]
>>> >
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]