You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Daniel Alonso Sanchez <da...@oc.mde.es> on 2008/08/21 11:44:32 UTC

[t5] Use messages from app.properties in java classes

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

-- 
View this message in context: http://www.nabble.com/-t5--Use-messages-from-app.properties-in-java-classes-tp19085534p19085534.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: [t5] Use messages from app.properties in java classes

Posted by Sven Homburg <ho...@googlemail.com>.
the MessagesBean class dont looks like a tapestry component,
if so, you cant inject via the @Inject annotation

2008/8/21 Daniel Alonso Sanchez <da...@oc.mde.es>

>
> 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
>
> --
> View this message in context:
> http://www.nabble.com/-t5--Use-messages-from-app.properties-in-java-classes-tp19085534p19085534.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
with regards
Sven Homburg
http://www.chenillekit.org
http://tapestry5-components.googlecode.com

Re: [t5] Use messages from app.properties in java classes

Posted by Daniel Alonso Sanchez <da...@oc.mde.es>.


Sven Homburg wrote:
> 
> look for that, that should helps you
> http://pastebin.com/f2a26b195
> 
> -----
> best regards
> Sven
> 


Thanks a lot again, Sven. Your help is very much aprecciated ;D. The Proxy
in my lan is deniying me of accessing to that link, so i will check it when
i arrive at home.
-- 
View this message in context: http://www.nabble.com/-t5--Use-messages-from-app.properties-in-java-classes-tp19085534p19086722.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: [t5] Use messages from app.properties in java classes

Posted by Sven Homburg <ho...@googlemail.com>.
look for that, that should helps you
http://pastebin.com/f2a26b195

2008/8/21 Daniel Alonso Sanchez <da...@oc.mde.es>

>
>
>
> Andy Pahne-3 wrote:
> >
> >
> >> 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?
> >>
> >
> > This works in component classes, pages and mixins. Basicly in all your
> > applications classes that get "enhanced" by Tapestry IOC.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
> Thanks, Sven. I think that is my problem. I inject the Resource in a class
> that is not a page, nor a component or mixin. Maybe is that, isn't it?
>
> Now the key is how i can do what i need... I will give a hard thought.
>
> Thanks a lot
>
> --
> View this message in context:
> http://www.nabble.com/-t5--Use-messages-from-app.properties-in-java-classes-tp19085534p19086406.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
with regards
Sven Homburg
http://www.chenillekit.org
http://tapestry5-components.googlecode.com

Re: [t5] Use messages from app.properties in java classes

Posted by Daniel Alonso Sanchez <da...@oc.mde.es>.


Andy Pahne-3 wrote:
> 
> 
>> 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?
>> 
> 
> This works in component classes, pages and mixins. Basicly in all your 
> applications classes that get "enhanced" by Tapestry IOC.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

Thanks, Sven. I think that is my problem. I inject the Resource in a class
that is not a page, nor a component or mixin. Maybe is that, isn't it?

Now the key is how i can do what i need... I will give a hard thought. 

Thanks a lot 

-- 
View this message in context: http://www.nabble.com/-t5--Use-messages-from-app.properties-in-java-classes-tp19085534p19086406.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: [t5] Use messages from app.properties in java classes

Posted by Sven Homburg <ho...@googlemail.com>.
>Basicly in all your applications classes that get "enhanced" by Tapestry
IOC.
thats not right
the @Inject annotation only works in components, pages and mixins

2008/8/21 Andy Pahne <ap...@net22.de>

>
>  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?
>>
>>
> This works in component classes, pages and mixins. Basicly in all your
> applications classes that get "enhanced" by Tapestry IOC.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
with regards
Sven Homburg
http://www.chenillekit.org
http://tapestry5-components.googlecode.com

Re: [t5] Use messages from app.properties in java classes

Posted by Andy Pahne <ap...@net22.de>.
> 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?
> 

This works in component classes, pages and mixins. Basicly in all your 
applications classes that get "enhanced" by Tapestry IOC.


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


Re: [t5] Use messages from app.properties in java classes

Posted by Daniel Alonso Sanchez <da...@oc.mde.es>.


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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 


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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [t5] Use messages from app.properties in java classes

Posted by Andy Pahne <ap...@net22.de>.
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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org