Re: Localized string retrieved with a warning message

2008-09-18 Thread Erik van Oosten


Are you sure that message is coming from this code? This code looks 
quite alright to me (though you could replace StringResourceModel(x, 
this, null) with ResourceModel(x), and change the parameter type to 
IModel).


Regards,
   Erik.


Azzeddine Daddah wrote:

Thanks Michael,

I did but the warnings are still displayed.

private void addLinks() {
addLink("home", new StringResourceModel("navigationbar.menu.home",
this, null), HomePage.class);
addLink("numberPool", new
StringResourceModel("navigationbar.menu.numberpool", this, null),
NumberPoolPage.class);
addLink("numberPoolLog", new
StringResourceModel("navigationbar.menu.numberpoollog", this, null),
NumberPoolLogPage.class);
addLink("defragment", new
StringResourceModel("navigationbar.menu.defragment", this, null),
DefragmentPage.class);
addLink("search", new
StringResourceModel("navigationbar.menu.search", this, null),
SearchPage.class);
}

private void addLink(String id, StringResourceModel model, final Class pageClass) {
BookmarkablePageLink link = new BookmarkablePageLink(id, pageClass);
link.add(new AttributeModifier("class", true, new
AbstractReadOnlyModel() {
private static final long serialVersionUID = 1L;

@Override
public Object getObject() {
String currentPageName = pageClass.getName();
String parentPageName  = getPage().getClass().getName();
return StringUtils.equals(currentPageName, parentPageName) ?
"current_page_item" : AttributeModifier.VALUELESS_ATTRIBUTE_REMOVE;
}

}));
link.add(new Label("title", model));
add(link);
}

Gr. Azzeddine

  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Localized string retrieved with a warning message

2008-09-18 Thread Azzeddine Daddah
Thanks Michael,

I did but the warnings are still displayed.

private void addLinks() {
addLink("home", new StringResourceModel("navigationbar.menu.home",
this, null), HomePage.class);
addLink("numberPool", new
StringResourceModel("navigationbar.menu.numberpool", this, null),
NumberPoolPage.class);
addLink("numberPoolLog", new
StringResourceModel("navigationbar.menu.numberpoollog", this, null),
NumberPoolLogPage.class);
addLink("defragment", new
StringResourceModel("navigationbar.menu.defragment", this, null),
DefragmentPage.class);
addLink("search", new
StringResourceModel("navigationbar.menu.search", this, null),
SearchPage.class);
}

private void addLink(String id, StringResourceModel model, final Class pageClass) {
BookmarkablePageLink link = new BookmarkablePageLink(id, pageClass);
link.add(new AttributeModifier("class", true, new
AbstractReadOnlyModel() {
private static final long serialVersionUID = 1L;

@Override
public Object getObject() {
String currentPageName = pageClass.getName();
String parentPageName  = getPage().getClass().getName();
return StringUtils.equals(currentPageName, parentPageName) ?
"current_page_item" : AttributeModifier.VALUELESS_ATTRIBUTE_REMOVE;
}

}));
link.add(new Label("title", model));
add(link);
}

Gr. Azzeddine

On Thu, Sep 18, 2008 at 9:29 AM, Michael Sparer <[EMAIL PROTECTED]>wrote:

>
> Don't call getString() on your final StringResourceModels, rather just pass
> the models to the links, then you shouldn't bet the warning anymore
>
> regards,
> Michael
>
> Azzeddine Daddah wrote:
> >
> > Hi,
> >
> > I get the following warning message when trying to retrieve a localized
> > string: *Tried to retrieve a localized string for a component that has
> not
> > yet been added to the page. This can sometimes lead to an invalid or no
> > localized resource returned. Make sure you are not calling
> > Component#getString() inside your Component's constructor. Offending
> > component*
> >
> > This how my code look like:
> > public class NavigationBarPanel extends Panel {
> >
> > private static final long serialVersionUID = 1L;
> > /** The navigation bar links */
> > private final String MENU_MENU = new
> > StringResourceModel("navigationbar.menu.home", this, null).getString();
> > private final String NUMBER_POOL_MENU = new
> > StringResourceModel("navigationbar.menu.numberpool", this,
> > null).getString();
> > private final String NUMBER_POOL_LOG_MENU = new
> > StringResourceModel("navigationbar.menu.numberpoollog", this,
> > null).getString();
> > private final String DEFRAGMENT_MENU = new
> > StringResourceModel("navigationbar.menu.defragment", this,
> > null).getString();
> > private final String SEARCH_MENU = new
> > StringResourceModel("navigationbar.menu.search", this, null).getString();
> >
> > public NavigationBarPanel(String id) {
> > super(id);
> > addLinks();
> > }
> >
> > private void addLinks() {
> > addLink("home", MENU_MENU, HomePage.class);
> > addLink("numberPool", NUMBER_POOL_MENU, NumberPoolPage.class);
> > addLink("numberPoolLog", NUMBER_POOL_LOG_MENU,
> > NumberPoolLogPage.class);
> > addLink("defragment", DEFRAGMENT_MENU, DefragmentPage.class);
> > addLink("search", SEARCH_MENU, SearchPage.class);
> > }
> >
> > private void addLink(String id, String title, final Class > Page> pageClass) {
> > BookmarkablePageLink link = new BookmarkablePageLink(id,
> > pageClass);
> > link.add(new AttributeModifier("class", true, new
> > AbstractReadOnlyModel() {
> > private static final long serialVersionUID = 1L;
> >
> > @Override
> > public Object getObject() {
> > String currentPageName = pageClass.getName();
> > String parentPageName  = getPage().getClass().getName();
> > return StringUtils.equals(currentPageName,
> parentPageName)
> > ?
> > "current_page_item" : AttributeModifier.VALUELESS_ATTRIBUTE_REMOVE;
> > }
> >
> > }));
> > link.add(new Label("title", new Model(title)));
> > add(link);
> > }
> > }
> >
> > Could you please tell me why am I getting this warning. I use the same
> > strategy to add localized string to my pages but I don't get warnings.
> >
> > Gr. Azzeddine
> >
> >
>
>
> -
> Michael Sparer
> http://talk-on-tech.blogspot.com
> --
> View this message in context:
> http://www.nabble.com/Localized-string-retrieved-with-a-warning-message-tp19547462p19547514.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Azzeddine Daddah
www.hbi

Re: Localized string retrieved with a warning message

2008-09-18 Thread Michael Sparer

Don't call getString() on your final StringResourceModels, rather just pass
the models to the links, then you shouldn't bet the warning anymore

regards, 
Michael

Azzeddine Daddah wrote:
> 
> Hi,
> 
> I get the following warning message when trying to retrieve a localized
> string: *Tried to retrieve a localized string for a component that has not
> yet been added to the page. This can sometimes lead to an invalid or no
> localized resource returned. Make sure you are not calling
> Component#getString() inside your Component's constructor. Offending
> component*
> 
> This how my code look like:
> public class NavigationBarPanel extends Panel {
> 
> private static final long serialVersionUID = 1L;
> /** The navigation bar links */
> private final String MENU_MENU = new
> StringResourceModel("navigationbar.menu.home", this, null).getString();
> private final String NUMBER_POOL_MENU = new
> StringResourceModel("navigationbar.menu.numberpool", this,
> null).getString();
> private final String NUMBER_POOL_LOG_MENU = new
> StringResourceModel("navigationbar.menu.numberpoollog", this,
> null).getString();
> private final String DEFRAGMENT_MENU = new
> StringResourceModel("navigationbar.menu.defragment", this,
> null).getString();
> private final String SEARCH_MENU = new
> StringResourceModel("navigationbar.menu.search", this, null).getString();
> 
> public NavigationBarPanel(String id) {
> super(id);
> addLinks();
> }
> 
> private void addLinks() {
> addLink("home", MENU_MENU, HomePage.class);
> addLink("numberPool", NUMBER_POOL_MENU, NumberPoolPage.class);
> addLink("numberPoolLog", NUMBER_POOL_LOG_MENU,
> NumberPoolLogPage.class);
> addLink("defragment", DEFRAGMENT_MENU, DefragmentPage.class);
> addLink("search", SEARCH_MENU, SearchPage.class);
> }
> 
> private void addLink(String id, String title, final Class Page> pageClass) {
> BookmarkablePageLink link = new BookmarkablePageLink(id,
> pageClass);
> link.add(new AttributeModifier("class", true, new
> AbstractReadOnlyModel() {
> private static final long serialVersionUID = 1L;
> 
> @Override
> public Object getObject() {
> String currentPageName = pageClass.getName();
> String parentPageName  = getPage().getClass().getName();
> return StringUtils.equals(currentPageName, parentPageName)
> ?
> "current_page_item" : AttributeModifier.VALUELESS_ATTRIBUTE_REMOVE;
> }
> 
> }));
> link.add(new Label("title", new Model(title)));
> add(link);
> }
> }
> 
> Could you please tell me why am I getting this warning. I use the same
> strategy to add localized string to my pages but I don't get warnings.
> 
> Gr. Azzeddine
> 
> 


-
Michael Sparer
http://talk-on-tech.blogspot.com
-- 
View this message in context: 
http://www.nabble.com/Localized-string-retrieved-with-a-warning-message-tp19547462p19547514.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]