You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Anders <in...@gmail.com> on 2008/11/14 06:51:09 UTC

How can I use I18N in panel before add panel to a page?

Hi,

I writed my own wicket panel component, and this component contains a label.
I use Component's getString() to set label's model, like:

  *//constructor*
*  public InvoiceWaferDataSetPanel(String id, InvoiceWaferDataSet dataSet)
  {
    super(id);
    setModel(new CompoundPropertyModel(dataSet));
...
    add(new Label("subTotal", getString("subTotal")).add(new
AttributeModifier("style", true, new Model(dataSet.getSize() >
1?"":"display:none"))));
...
  }*

but below is warning message from wicket:

*[Localizer] 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: [MarkupContainer [Component id = dataSet, page = <No Page>, path
= dataSet.InvoiceWaferDataSetPanel]]*

I defined I18N string in application properties file, like:
subTotal = Sub Total

Can anyone tell me how to solve this problem?

-- 
−−−−−−−−−−−−−−−−−−
~Mia は 最高!~
−−−−−−−−−−−−−−−−−−

Re: How can I use I18N in panel before add panel to a page?

Posted by Anders <in...@gmail.com>.
Thank you, Jeremy.

2008/11/14 Jeremy Thomerson <je...@wickettraining.com>

> Use StringResourceModel.
>
> 2008/11/13 Anders <in...@gmail.com>
>
> > Hi,
> >
> > I writed my own wicket panel component, and this component contains a
> > label.
> > I use Component's getString() to set label's model, like:
> >
> >  *//constructor*
> > *  public InvoiceWaferDataSetPanel(String id, InvoiceWaferDataSet
> dataSet)
> >  {
> >    super(id);
> >    setModel(new CompoundPropertyModel(dataSet));
> > ...
> >    add(new Label("subTotal", getString("subTotal")).add(new
> > AttributeModifier("style", true, new Model(dataSet.getSize() >
> > 1?"":"display:none"))));
> > ...
> >  }*
> >
> > but below is warning message from wicket:
> >
> > *[Localizer] 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: [MarkupContainer [Component id = dataSet, page = <No Page>,
> path
> > = dataSet.InvoiceWaferDataSetPanel]]*
> >
> > I defined I18N string in application properties file, like:
> > subTotal = Sub Total
> >
> > Can anyone tell me how to solve this problem?
> >
> > --
> > −−−−−−−−−−−−−−−−−−
> > ~Mia は 最高!~
> > −−−−−−−−−−−−−−−−−−
> >
>
>
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>



-- 
−−−−−−−−−−−−−−−−−−
~Mia は 最高!~
−−−−−−−−−−−−−−−−−−

Re: How can I use I18N in panel before add panel to a page?

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Use StringResourceModel.

2008/11/13 Anders <in...@gmail.com>

> Hi,
>
> I writed my own wicket panel component, and this component contains a
> label.
> I use Component's getString() to set label's model, like:
>
>  *//constructor*
> *  public InvoiceWaferDataSetPanel(String id, InvoiceWaferDataSet dataSet)
>  {
>    super(id);
>    setModel(new CompoundPropertyModel(dataSet));
> ...
>    add(new Label("subTotal", getString("subTotal")).add(new
> AttributeModifier("style", true, new Model(dataSet.getSize() >
> 1?"":"display:none"))));
> ...
>  }*
>
> but below is warning message from wicket:
>
> *[Localizer] 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: [MarkupContainer [Component id = dataSet, page = <No Page>, path
> = dataSet.InvoiceWaferDataSetPanel]]*
>
> I defined I18N string in application properties file, like:
> subTotal = Sub Total
>
> Can anyone tell me how to solve this problem?
>
> --
> −−−−−−−−−−−−−−−−−−
> ~Mia は 最高!~
> −−−−−−−−−−−−−−−−−−
>



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