You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by msantos <mp...@gmail.com> on 2010/09/06 15:00:10 UTC

StringResourceModel - On the Fly

Hello there. 

I am using the StringResourceModel to get from the *.properties file strings
to the pages of my web app. and it is working fine.

For instance: 

StringResourceModel emailLabelModel = new StringResourceModel("emailLabel",
null);
emailLabel = new Label("emailLabel", emailLabelModel);

But when i need string from the file on the fly, not on the rendering fase,
it raise an exception:

StringResourceModel resultadoMsgModel = new StringResourceModel("msgResult",
null);
resultadoMsgModel.getString();

java.util.MissingResourceException: Unable to find property: 'msgResult'

Someone can explain why it happens and how can i get it work?

Thanks a lot
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/StringResourceModel-On-the-Fly-tp2528345p2528345.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: StringResourceModel - On the Fly

Posted by msantos <mp...@gmail.com>.
Hi there.

Is really this that i was looking for. Passing the Panel instance to the
component variable, it finds the respective property file and returns the
value.

Thanks a lot man.... 5* to your help

See ya
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/StringResourceModel-On-the-Fly-tp2528345p2535954.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: StringResourceModel - On the Fly

Posted by Matthias Keller <ma...@ergon.ch>.
Hi

Why not use one of the various methods on the localizer?
getLocalizer().getString(...)
Or if not in a component
Application.get().getResourceSettings().getLocalizer().getString(...)

Matt

On 2010-09-06 19:26, msantos wrote:
> Thats solve the problem. I already have a resource bundle on the application,
> but i was trying to eliminate it and just use the wicket StringResourceModel
> witch is more easy to maintain all the pages of the application.
>
> If there is no way to get the string from the .properties file of the page
> on that moment, a i guess i will use the Java ResourceBundle.
>
> Thank you all
>    




Re: StringResourceModel - On the Fly

Posted by msantos <mp...@gmail.com>.
Thats solve the problem. I already have a resource bundle on the application,
but i was trying to eliminate it and just use the wicket StringResourceModel
witch is more easy to maintain all the pages of the application.

If there is no way to get the string from the .properties file of the page
on that moment, a i guess i will use the Java ResourceBundle.

Thank you all
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/StringResourceModel-On-the-Fly-tp2528345p2528689.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: StringResourceModel - On the Fly

Posted by Pedro Santos <pe...@gmail.com>.
Won't be reasonable use ResourceBundle directly in your case? Like:
ResourceBundle.getBundle( *.properties, locale).getString("msgResult")
Otherwise StringResourceModel just would delegate your call to this api...

On Mon, Sep 6, 2010 at 10:00 AM, msantos <mp...@gmail.com> wrote:

>
> Hello there.
>
> I am using the StringResourceModel to get from the *.properties file
> strings
> to the pages of my web app. and it is working fine.
>
> For instance:
>
> StringResourceModel emailLabelModel = new StringResourceModel("emailLabel",
> null);
> emailLabel = new Label("emailLabel", emailLabelModel);
>
> But when i need string from the file on the fly, not on the rendering fase,
> it raise an exception:
>
> StringResourceModel resultadoMsgModel = new
> StringResourceModel("msgResult",
> null);
> resultadoMsgModel.getString();
>
> java.util.MissingResourceException: Unable to find property: 'msgResult'
>
> Someone can explain why it happens and how can i get it work?
>
> Thanks a lot
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/StringResourceModel-On-the-Fly-tp2528345p2528345.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Pedro Henrique Oliveira dos Santos

Re: StringResourceModel - On the Fly

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.
To be more clear I will paste some code:

public class Foo
{
	public String getSomething()
	{
		frase = "field " + filterData.getFieldName() + " of " +
criteria.getDescription() + " is equal to " +
filter.getDataValue().getValue();
			
	{

}

Should be translated to something similar to

"field ${fieldName} of ${fieldDescription} is equal to
${fieldDataValue}"

And have a way to access this as if we were in a component.

But how to do it inside a class that is not a component?

        

El lun, 06-09-2010 a las 18:41 +0200, Gonzalo Aguilar Delgado escribió:
> Hi MSantos, 
> 
> I have similar problem. I want to localize a string inside a class, but
> I think your approach is not the good solution. I will look around but
> If someone has any alternatives please say...
> 
> 
> Tnx.
> 
> 
> El lun, 06-09-2010 a las 06:00 -0700, msantos escribió:
> > Hello there. 
> > 
> > I am using the StringResourceModel to get from the *.properties file strings
> > to the pages of my web app. and it is working fine.
> > 
> > For instance: 
> > 
> > StringResourceModel emailLabelModel = new StringResourceModel("emailLabel",
> > null);
> > emailLabel = new Label("emailLabel", emailLabelModel);
> > 
> > But when i need string from the file on the fly, not on the rendering fase,
> > it raise an exception:
> > 
> > StringResourceModel resultadoMsgModel = new StringResourceModel("msgResult",
> > null);
> > resultadoMsgModel.getString();
> > 
> > java.util.MissingResourceException: Unable to find property: 'msgResult'
> > 
> > Someone can explain why it happens and how can i get it work?
> > 
> > Thanks a lot
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


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


Re: StringResourceModel - On the Fly

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.
Hi MSantos, 

I have similar problem. I want to localize a string inside a class, but
I think your approach is not the good solution. I will look around but
If someone has any alternatives please say...


Tnx.


El lun, 06-09-2010 a las 06:00 -0700, msantos escribió:
> Hello there. 
> 
> I am using the StringResourceModel to get from the *.properties file strings
> to the pages of my web app. and it is working fine.
> 
> For instance: 
> 
> StringResourceModel emailLabelModel = new StringResourceModel("emailLabel",
> null);
> emailLabel = new Label("emailLabel", emailLabelModel);
> 
> But when i need string from the file on the fly, not on the rendering fase,
> it raise an exception:
> 
> StringResourceModel resultadoMsgModel = new StringResourceModel("msgResult",
> null);
> resultadoMsgModel.getString();
> 
> java.util.MissingResourceException: Unable to find property: 'msgResult'
> 
> Someone can explain why it happens and how can i get it work?
> 
> Thanks a lot


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