You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tina Umlandt <ti...@compuserve.de> on 2007/06/26 17:56:51 UTC

Messages and @inject

hi,

I need my own implementation of the Messages interface. It works fine with the new binding in the HTML-templates. But I 
have a problem to use it as a field in a the class. I tried the following

@Inject
@Service ( "myMessages" )
Messages _message;

I hoped the Injection would know that I use my own implementation but it is totally ignored. The tapestry messages are 
injected.

I created a little workaround by implementing a mock interface which extends the Messages interface so that the 
injection work properly.

@Inject
MyMessages _message;

But I don't really like it that way.

The question that I have is:

Is this effect wanted that the user cannot inject his own Messages implementation or is it something nobody thought of?

Thanks and regards,
	Tina

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Antwort: Messages and @inject

Posted by Tina Umlandt <ti...@compuserve.de>.
Well. now I know what you mean ;-)

This is the part my colleagues were doing so I missed this the previous 
times :-(.

But thx a lot and yes, I think this is the right time to read the docs 
again ...


Kristian Marinkovic wrote:
> before you inject a service you must tell the ioc container how to 
> create it (in your AppModule). you can  do this by using the 
> ServiceBinder:
>
>     public static void bind(ServiceBinder binder) {
>         binder.bind(MyService.class,MyServiceImpl.class); 
>     }
>
> Or you can provide a builder method:
>
> public static Message buildMyMessage() {
>     return new MyMessage();
> }
>
> there's some information in the tapestry-ioc docs :)
>
> g,
> kris
>
>
>
>
>
>
> Tina Umlandt <ti...@compuserve.de> 
> 27.06.2007 13:50
> Bitte antworten an
> "Tapestry users" <us...@tapestry.apache.org>
>
>
> An
> Tapestry users <us...@tapestry.apache.org>
> Kopie
>
> Thema
> Re: Antwort: Messages and @inject
>
>
>
>
>
>
> Hej,
>
> I didn't add anything to my AppModule. Do I have to? Which method do you 
> mean?
>
> Thx,
>     Tina
>
>
>
> Kristian Marinkovic wrote:
>   
>> it should work as you've tried.... could you post the code from 
>> your AppModule where you return your service?
>>
>>
>>
>>
>>
>> Tina Umlandt <ti...@compuserve.de> 
>> 26.06.2007 17:56
>> Bitte antworten an
>> "Tapestry users" <us...@tapestry.apache.org>
>>
>>
>> An
>> Tapestry users <us...@tapestry.apache.org>
>> Kopie
>>
>> Thema
>> Messages and @inject
>>
>>
>>
>>
>>
>>
>> hi,
>>
>> I need my own implementation of the Messages interface. It works fine 
>>     
> with 
>   
>> the new binding in the HTML-templates. But I 
>> have a problem to use it as a field in a the class. I tried the 
>>     
> following
>   
>> @Inject
>> @Service ( "myMessages" )
>> Messages _message;
>>
>> I hoped the Injection would know that I use my own implementation but it 
>>     
>
>   
>> is totally ignored. The tapestry messages are 
>> injected.
>>
>> I created a little workaround by implementing a mock interface which 
>> extends the Messages interface so that the 
>> injection work properly.
>>
>> @Inject
>> MyMessages _message;
>>
>> But I don't really like it that way.
>>
>> The question that I have is:
>>
>> Is this effect wanted that the user cannot inject his own Messages 
>> implementation or is it something nobody thought of?
>>
>> Thanks and regards,
>>                  Tina
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>>
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Antwort: Messages and @inject

Posted by Kristian Marinkovic <kr...@porsche.co.at>.
before you inject a service you must tell the ioc container how to 
create it (in your AppModule). you can  do this by using the 
ServiceBinder:

    public static void bind(ServiceBinder binder) {
        binder.bind(MyService.class,MyServiceImpl.class); 
    }

Or you can provide a builder method:

public static Message buildMyMessage() {
    return new MyMessage();
}

there's some information in the tapestry-ioc docs :)

g,
kris






Tina Umlandt <ti...@compuserve.de> 
27.06.2007 13:50
Bitte antworten an
"Tapestry users" <us...@tapestry.apache.org>


An
Tapestry users <us...@tapestry.apache.org>
Kopie

Thema
Re: Antwort: Messages and @inject






Hej,

I didn't add anything to my AppModule. Do I have to? Which method do you 
mean?

Thx,
    Tina



Kristian Marinkovic wrote:
> it should work as you've tried.... could you post the code from 
> your AppModule where you return your service?
>
>
>
>
>
> Tina Umlandt <ti...@compuserve.de> 
> 26.06.2007 17:56
> Bitte antworten an
> "Tapestry users" <us...@tapestry.apache.org>
>
>
> An
> Tapestry users <us...@tapestry.apache.org>
> Kopie
>
> Thema
> Messages and @inject
>
>
>
>
>
>
> hi,
>
> I need my own implementation of the Messages interface. It works fine 
with 
> the new binding in the HTML-templates. But I 
> have a problem to use it as a field in a the class. I tried the 
following
>
> @Inject
> @Service ( "myMessages" )
> Messages _message;
>
> I hoped the Injection would know that I use my own implementation but it 

> is totally ignored. The tapestry messages are 
> injected.
>
> I created a little workaround by implementing a mock interface which 
> extends the Messages interface so that the 
> injection work properly.
>
> @Inject
> MyMessages _message;
>
> But I don't really like it that way.
>
> The question that I have is:
>
> Is this effect wanted that the user cannot inject his own Messages 
> implementation or is it something nobody thought of?
>
> Thanks and regards,
>                  Tina
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org



Re: Antwort: Messages and @inject

Posted by Tina Umlandt <ti...@compuserve.de>.
Hej,

I didn't add anything to my AppModule. Do I have to? Which method do you 
mean?

Thx,
    Tina



Kristian Marinkovic wrote:
> it should work as you've tried.... could you post the code from 
> your AppModule where you return your service?
>
>
>
>
>
> Tina Umlandt <ti...@compuserve.de> 
> 26.06.2007 17:56
> Bitte antworten an
> "Tapestry users" <us...@tapestry.apache.org>
>
>
> An
> Tapestry users <us...@tapestry.apache.org>
> Kopie
>
> Thema
> Messages and @inject
>
>
>
>
>
>
> hi,
>
> I need my own implementation of the Messages interface. It works fine with 
> the new binding in the HTML-templates. But I 
> have a problem to use it as a field in a the class. I tried the following
>
> @Inject
> @Service ( "myMessages" )
> Messages _message;
>
> I hoped the Injection would know that I use my own implementation but it 
> is totally ignored. The tapestry messages are 
> injected.
>
> I created a little workaround by implementing a mock interface which 
> extends the Messages interface so that the 
> injection work properly.
>
> @Inject
> MyMessages _message;
>
> But I don't really like it that way.
>
> The question that I have is:
>
> Is this effect wanted that the user cannot inject his own Messages 
> implementation or is it something nobody thought of?
>
> Thanks and regards,
>                  Tina
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Antwort: Messages and @inject

Posted by Kristian Marinkovic <kr...@porsche.co.at>.
it should work as you've tried.... could you post the code from 
your AppModule where you return your service?





Tina Umlandt <ti...@compuserve.de> 
26.06.2007 17:56
Bitte antworten an
"Tapestry users" <us...@tapestry.apache.org>


An
Tapestry users <us...@tapestry.apache.org>
Kopie

Thema
Messages and @inject






hi,

I need my own implementation of the Messages interface. It works fine with 
the new binding in the HTML-templates. But I 
have a problem to use it as a field in a the class. I tried the following

@Inject
@Service ( "myMessages" )
Messages _message;

I hoped the Injection would know that I use my own implementation but it 
is totally ignored. The tapestry messages are 
injected.

I created a little workaround by implementing a mock interface which 
extends the Messages interface so that the 
injection work properly.

@Inject
MyMessages _message;

But I don't really like it that way.

The question that I have is:

Is this effect wanted that the user cannot inject his own Messages 
implementation or is it something nobody thought of?

Thanks and regards,
                 Tina

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org