Andy Pahne-3 wrote:
>
>
> First of all you inject ComponentResources:
>
> @Inject
> private ComponentResources resources;
>
>
> Then, you can do this:
>
> String message = resources.getMessages().get("some-message");
>
>
> I am not aware if you can inject Messages directly, but I would not be
> surprised if you could somehow.
>
>
> Andy
>
>
> Daniel Alonso Sanchez schrieb:
>> Hi again to everybody, sorry for dsiturbing again, but i have spent at
>> least
>> two hours reading the docs, wiki, Tapestry in Action book, but... i can't
>> solve my actual problem.
>>
>> The thing is that i'm trying to create a MessagesComponent: a component
>> that
>> let's to add aliases, and before insert them into a list, it looks for
>> them
>> into app.properties file.
>>
>> public class MessagesBean {
>> private List<String> mensajes;
>> private String mensaje;
>> @Inject
>> private Messages messages;
>> public MessagesBean() {
>> super();
>> mensajes=new ArrayList<String>();
>> }
>>
>> public List<String> getMensajes() {
>> return mensajes;
>> }
>> public void setMensajes(List<String> mensajes) {
>> this.mensajes = mensajes;
>> }
>>
>> public String getMensaje() {
>> return mensaje;
>> }
>>
>> public void setMensaje(String mensaje) {
>> this.mensaje = mensaje;
>> }
>> public void addMensaje(String mensaje){
>> String cadena=null;
>> cadena=messages.get("hibernateexception");
>> mensajes.add (cadena);
>> mensajes.add(mensaje);
>> }
>> public boolean getContieneMensajes(){
>> return (mensajes.size()>0);
>> }
>>
>> }
>>
>> And this is my app.properties
>> -------------
>> hibernateexception=what a mess :D
>> -------------
>>
>> The thing is that property Messages (org.apache.tapestry5.ioc.Messages),
>> is
>> null, and i can't get any message from it. I know that i missing
>> something,
>> but i don't know what it is :confused:
>>
>> May anyone help me again? Thanks in advance for it
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
Thanks a lot for your response, but the problem still remains :-((. I have
insert this code
---------
@Inject
private ComponentResources resources;
------------
and
-------------
resources.getMessages().get("hibernateexception");
------------
but i get a null value for "resources" object. Am i missing something in
AppModule.java?
--
View this message in context:
http://www.nabble.com/-t5--Use-messages-from-app.properties-in-java-classes-tp19085534p19086167.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]