In which app.xml file is it in?  An XML properties file?  Or in some Spring
(etc) config file?

String loading from Wicket's built in resources framework is quite robust.
If you have a .properties file (or .xml properties file if you choose -
certain languages require this format because of encoding) named the same as
your application (MyApp.java = MyApp.properties or MyApp.xml), then you can
use string loading just like if it were MyComponent.java and
MyComponent.properties.  This is well documented in Wicket in Action, which
leads me to believe that you are talking rather about some app.xml Spring
config.  In which case, you'll probably need to add a resource locator in
your application's init method to locate resources in custom locations.

--
Jeremy Thomerson
http://www.wickettraining.com



On Thu, Mar 12, 2009 at 12:30 PM, Seven Corners <shel...@blackwave.tv>wrote:

>
> Thank you for giving such an explicit answer, Steve.  The thing is, I do
> that
> all the time, and this is the answer for when you have an associated
> component.  I am looking for how to do it with strings shared throughout
> the
> WebApplication; i.e., there is no component and the string is in the
> application's xml file.  I've looked all over Wicket in Action and perhaps
> it's in there, but I just can't find it.  That's why I'm posting.
>
> So I have the string I need in my app.xml.  Within a panel on one of the
> pages, I instantiate a StringResourceModel with a string ID from the
> app.xml
> file like so:
>
> class MyPanel extends Panel
> {
>    ...
>    add( new Label( strLabelId, new StringResourceModel( strRescId, null ) )
> );
>    ...
> }
>
> I'm guessing I need to use the StringResourceModel(String resourceKey,
> IModel<?> model)  ctor because the string is not associated with a
> component, and I'm setting the model to null because ultimately I'd be
> getting the value from a bean if I did and the bean can't return the string
> for the same reason I'm having troubles, namely that it's not a component
> so
> it can't have a properties file associated with it.
>
> I get a runtime exception that it can't find that string for my component,
> which makes perfect sense.  I understand why it fails.  I can kludge a
> workaround.  I don't want to; I know you have the capability to create a
> shared string table and I want to do it right.
>
> So what am I doing wrong?
>
>
> Steve Swinsburg-2 wrote:
> >
> > You can also just use ResourceModel("some.string.property") if you
> > don't have any thing that needs to be substituted into the strings
> > when they are rendered.
> > ie
> > some.string.property=this is some text
> >
> > or StringResourceModel( various constructors ) if you need some
> > dynamic value in there:
> > ie
> > some.string.property=This is a {0} string
> >
> > This will work from the same YourApplicationName.properties file.
> >
> >
> > cheers,
> > Steve
> >
> >
> >
> > On 11/03/2009, at 7:24 PM, Jeremy Thomerson wrote:
> >
> >> Put them in YourApplicationName.properties and use
> >> StringResourceModel.  See
> >> internationalization help in Wicket in Action.
> >>
> >> --
> >> Jeremy Thomerson
> >> http://www.wickettraining.com
> >>
> >>
> >>
> >> On Wed, Mar 11, 2009 at 2:20 PM, Seven Corners
> >> <shel...@blackwave.tv> wrote:
> >>
> >>>
> >>> I have some strings that I'd like to access from a common string
> >>> table that
> >>> is not tied to any particular component.  How can I do this?
> >>> --
> >>> View this message in context:
> >>> http://www.nabble.com/Shared-string-resources-
> >>> tp22462537p22462537.html
> >>> Sent from the Wicket - User mailing list archive at Nabble.com.
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >>> For additional commands, e-mail: users-h...@wicket.apache.org
> >>>
> >>>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Shared-string-resources-tp22462537p22481472.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to