You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by OjO <fa...@washington.edu> on 2009/06/26 23:03:57 UTC
Re: localizer and variables
I am using the following:
myCom.setMarkupId (getLocalizer().getString ("handle", MyPanel.this, new
Model (handleId)));
but still getting WARNing:
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.
What would be the correct way to get a property resource when a String value
is needed?
--
View this message in context: http://www.nabble.com/localizer-and-variables-tp16548684p24227247.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: localizer and variables
Posted by OjO <fa...@washington.edu>.
Thanks so much for all the responses, the "internal-externalized" issue is
clear now!
Now, the still unclear issue - when using a RepeatingView or a ListView to
create a list of links conditionally in a tool bar panel with their title
attributes and link labels in the i18n properties file, using "new
ResourceModel" for the Label works, is there a way to get the title String
(to add with SimpleAttributeModifier) without generating the
Component#getString() WARNing ?
luther.baker wrote:
>
> OjO,
>
> Ideally, strings or text that users actually see and interact with are
> candidates for i18n.
>
> javascript, markup ids, onclick attributes and the like need not be i18n.
> This kind of text can strictly be considered part of your codebase.
>
> Remember, strings exist in the i18n properties files to isolate them - so
> that their values can easily be *replaced *by other language specific text
> values ....
>
> Before putting strings there - ask yourself if you really need language
> specific versions of this 'string'.
>
> From your second example, it looks like the *editLink* is a fine candidate
> for an i18n string ... but using i18n string for the *markupid *and
> *onclick
> *handlers is actually confusing. That'd be like putting your <html> markup
> in an i18n properties file. It is code and has no international variant.
> Feel comfortable keeping those strings *internal*. Don't *externalize*
> them.
> Keep them collocated/embedded in the code - since they are themselves,
> code.
>
> I hope I didn't misunderstand you. Hope that helps,
>
> -Luther
>
>
>
> On Mon, Jun 29, 2009 at 5:06 PM, Igor Vaynberg
> <ig...@gmail.com>wrote:
>
>> an external resource can be any file that is not javacode.
>>
>> eg inside your panel you can do
>> Properties props=new Properties();
>>
>> props.load(getClassLoader().getResourceAsStream(getClass().getName().replace(".","/")+".external.properties"));
>>
>> and have a MyPanel.external.properties file next to your MyPanel.java
>>
>> i dont see why you are trying to externalize such strings though, they
>> are clearly part of the code.
>>
>> -igor
>>
>> On Mon, Jun 29, 2009 at 2:59 PM, OjO<fa...@washington.edu> wrote:
>> >
>> > Sorry, I did not mean to abuse them. I am seeking the right way of
>> getting
>> > String properties associated with a panel class. What do you mean by
>> > "externalized"? What is "an external resource"?
>> >
>> >
>> > igor.vaynberg wrote:
>> >>
>> >> the property files are made for i18n, you are really abusing them. if
>> >> you want these things externalized then load them from an external
>> >> resource yourself.
>> >>
>> >> -igor
>> >>
>> >> On Mon, Jun 29, 2009 at 12:14 PM, OjO<fa...@washington.edu> wrote:
>> >>>
>> >>> Here is another more complex case:
>> >>>
>> >>> LinkSelection.properties:
>> >>> edit_label=Edit
>> >>> done_label=Hide Edit...
>> >>> linkId=toggle_link_{id}
>> >>> onclick=toggleEdit('{id}'); return(false);
>> >>> divId=toggle_div_{id}
>> >>>
>> >>> LinkSelection.java has the following in the constructor:
>> >>> @Override
>> >>> protected void populateItem(ListItem item) {
>> >>>
>> >>> bk = (BkItemI)item.getModelObject();
>> >>>
>> >>> // 1. the edit icon
>> >>> Label editLink = new Label ("edit_item_link",
>> >>> ( isEditBk(bk)
>> >>> ? new ResourceModel
>> ("done_label")
>> >>> : new ResourceModel
>> >>> ("edit_label")))
>> >>> {
>> >>> @Override
>> >>> protected void onBeforeRender()
>> >>> {
>> >>> setOutputMarkupId(true);
>> >>> setMarkupId (getLocalizer().getString
>> >>> ("linkIdPrefix", LinkSelection.this,
>> >>> new PropertyModel
>> (LinkSelection.this.bk,
>> >>> "id")));
>> >>> add (new SimpleAttributeModifier
>> >>> ("onclick", getLocalizer().getString
>> >>> ("onclick", LinkSelection.this,
>> >>> new PropertyModel (LinkSelection.this.bk,
>> "id"))));
>> >>> super.onBeforeRender();
>> >>> }
>> >>> };
>> >>> item.add (editLink);
>> >>> ...
>> >>>
>> >>> ERROR 29 11:58:24.086 Error attaching this container for rendering:
>> >>> [MarkupContainer [Component id = 0]] [o.a.w.RequestCycle]
>> >>> org.apache.wicket.WicketRuntimeException: Error attaching this
>> container
>> >>> for
>> >>> rendering: [MarkupContainer [Component id = 0]]
>> >>> at
>> >>>
>> org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1717)
>> >>> at
>> org.apache.wicket.Component.onBeforeRender(Component.java:3757)
>> >>>
>> >>>
>> >>>
>> >>> igor.vaynberg wrote:
>> >>>>
>> >>>> set it in onbeforerender
>> >>>>
>> >>>> -igor
>> >>>>
>> >>>> On Fri, Jun 26, 2009 at 2:03 PM, OjO<fa...@washington.edu> wrote:
>> >>>>>
>> >>>>> I am using the following:
>> >>>>> myCom.setMarkupId (getLocalizer().getString ("handle",
>> MyPanel.this,
>> >>>>> new
>> >>>>> Model (handleId)));
>> >>>>>
>> >>>>> but still getting WARNing:
>> >>>>>
>> >>>>> 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.
>> >>>>>
>> >>>>> What would be the correct way to get a property resource when a
>> String
>> >>>>> value
>> >>>>> is needed?
>> >>>>> --
>> >>>>> View this message in context:
>> >>>>>
>> http://www.nabble.com/localizer-and-variables-tp16548684p24227247.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
>> >>>>>
>> >>>>>
>> >>>>
>> >>>>
>> ---------------------------------------------------------------------
>> >>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>>> For additional commands, e-mail: users-help@wicket.apache.org
>> >>>>
>> >>>>
>> >>>>
>> >>>
>> >>> --
>> >>> View this message in context:
>> >>>
>> http://www.nabble.com/localizer-and-variables-tp16548684p24259437.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
>> >>>
>> >>>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >>
>> >
>> > --
>> > View this message in context:
>> http://www.nabble.com/localizer-and-variables-tp16548684p24261681.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
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
--
View this message in context: http://www.nabble.com/localizer-and-variables-tp16548684p24276535.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: localizer and variables
Posted by Luther Baker <lu...@gmail.com>.
OjO,
Ideally, strings or text that users actually see and interact with are
candidates for i18n.
javascript, markup ids, onclick attributes and the like need not be i18n.
This kind of text can strictly be considered part of your codebase.
Remember, strings exist in the i18n properties files to isolate them - so
that their values can easily be *replaced *by other language specific text
values ....
Before putting strings there - ask yourself if you really need language
specific versions of this 'string'.
>From your second example, it looks like the *editLink* is a fine candidate
for an i18n string ... but using i18n string for the *markupid *and *onclick
*handlers is actually confusing. That'd be like putting your <html> markup
in an i18n properties file. It is code and has no international variant.
Feel comfortable keeping those strings *internal*. Don't *externalize* them.
Keep them collocated/embedded in the code - since they are themselves, code.
I hope I didn't misunderstand you. Hope that helps,
-Luther
On Mon, Jun 29, 2009 at 5:06 PM, Igor Vaynberg <ig...@gmail.com>wrote:
> an external resource can be any file that is not javacode.
>
> eg inside your panel you can do
> Properties props=new Properties();
>
> props.load(getClassLoader().getResourceAsStream(getClass().getName().replace(".","/")+".external.properties"));
>
> and have a MyPanel.external.properties file next to your MyPanel.java
>
> i dont see why you are trying to externalize such strings though, they
> are clearly part of the code.
>
> -igor
>
> On Mon, Jun 29, 2009 at 2:59 PM, OjO<fa...@washington.edu> wrote:
> >
> > Sorry, I did not mean to abuse them. I am seeking the right way of
> getting
> > String properties associated with a panel class. What do you mean by
> > "externalized"? What is "an external resource"?
> >
> >
> > igor.vaynberg wrote:
> >>
> >> the property files are made for i18n, you are really abusing them. if
> >> you want these things externalized then load them from an external
> >> resource yourself.
> >>
> >> -igor
> >>
> >> On Mon, Jun 29, 2009 at 12:14 PM, OjO<fa...@washington.edu> wrote:
> >>>
> >>> Here is another more complex case:
> >>>
> >>> LinkSelection.properties:
> >>> edit_label=Edit
> >>> done_label=Hide Edit...
> >>> linkId=toggle_link_{id}
> >>> onclick=toggleEdit('{id}'); return(false);
> >>> divId=toggle_div_{id}
> >>>
> >>> LinkSelection.java has the following in the constructor:
> >>> @Override
> >>> protected void populateItem(ListItem item) {
> >>>
> >>> bk = (BkItemI)item.getModelObject();
> >>>
> >>> // 1. the edit icon
> >>> Label editLink = new Label ("edit_item_link",
> >>> ( isEditBk(bk)
> >>> ? new ResourceModel
> ("done_label")
> >>> : new ResourceModel
> >>> ("edit_label")))
> >>> {
> >>> @Override
> >>> protected void onBeforeRender()
> >>> {
> >>> setOutputMarkupId(true);
> >>> setMarkupId (getLocalizer().getString
> >>> ("linkIdPrefix", LinkSelection.this,
> >>> new PropertyModel (LinkSelection.this.bk,
> >>> "id")));
> >>> add (new SimpleAttributeModifier
> >>> ("onclick", getLocalizer().getString
> >>> ("onclick", LinkSelection.this,
> >>> new PropertyModel (LinkSelection.this.bk,
> "id"))));
> >>> super.onBeforeRender();
> >>> }
> >>> };
> >>> item.add (editLink);
> >>> ...
> >>>
> >>> ERROR 29 11:58:24.086 Error attaching this container for rendering:
> >>> [MarkupContainer [Component id = 0]] [o.a.w.RequestCycle]
> >>> org.apache.wicket.WicketRuntimeException: Error attaching this
> container
> >>> for
> >>> rendering: [MarkupContainer [Component id = 0]]
> >>> at
> >>>
> org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1717)
> >>> at
> org.apache.wicket.Component.onBeforeRender(Component.java:3757)
> >>>
> >>>
> >>>
> >>> igor.vaynberg wrote:
> >>>>
> >>>> set it in onbeforerender
> >>>>
> >>>> -igor
> >>>>
> >>>> On Fri, Jun 26, 2009 at 2:03 PM, OjO<fa...@washington.edu> wrote:
> >>>>>
> >>>>> I am using the following:
> >>>>> myCom.setMarkupId (getLocalizer().getString ("handle", MyPanel.this,
> >>>>> new
> >>>>> Model (handleId)));
> >>>>>
> >>>>> but still getting WARNing:
> >>>>>
> >>>>> 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.
> >>>>>
> >>>>> What would be the correct way to get a property resource when a
> String
> >>>>> value
> >>>>> is needed?
> >>>>> --
> >>>>> View this message in context:
> >>>>>
> http://www.nabble.com/localizer-and-variables-tp16548684p24227247.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
> >>>>>
> >>>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>>
> >>>>
> >>>>
> >>>
> >>> --
> >>> View this message in context:
> >>> http://www.nabble.com/localizer-and-variables-tp16548684p24259437.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
> >>>
> >>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >>
> >
> > --
> > View this message in context:
> http://www.nabble.com/localizer-and-variables-tp16548684p24261681.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
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: localizer and variables
Posted by Igor Vaynberg <ig...@gmail.com>.
an external resource can be any file that is not javacode.
eg inside your panel you can do
Properties props=new Properties();
props.load(getClassLoader().getResourceAsStream(getClass().getName().replace(".","/")+".external.properties"));
and have a MyPanel.external.properties file next to your MyPanel.java
i dont see why you are trying to externalize such strings though, they
are clearly part of the code.
-igor
On Mon, Jun 29, 2009 at 2:59 PM, OjO<fa...@washington.edu> wrote:
>
> Sorry, I did not mean to abuse them. I am seeking the right way of getting
> String properties associated with a panel class. What do you mean by
> "externalized"? What is "an external resource"?
>
>
> igor.vaynberg wrote:
>>
>> the property files are made for i18n, you are really abusing them. if
>> you want these things externalized then load them from an external
>> resource yourself.
>>
>> -igor
>>
>> On Mon, Jun 29, 2009 at 12:14 PM, OjO<fa...@washington.edu> wrote:
>>>
>>> Here is another more complex case:
>>>
>>> LinkSelection.properties:
>>> edit_label=Edit
>>> done_label=Hide Edit...
>>> linkId=toggle_link_{id}
>>> onclick=toggleEdit('{id}'); return(false);
>>> divId=toggle_div_{id}
>>>
>>> LinkSelection.java has the following in the constructor:
>>> @Override
>>> protected void populateItem(ListItem item) {
>>>
>>> bk = (BkItemI)item.getModelObject();
>>>
>>> // 1. the edit icon
>>> Label editLink = new Label ("edit_item_link",
>>> ( isEditBk(bk)
>>> ? new ResourceModel ("done_label")
>>> : new ResourceModel
>>> ("edit_label")))
>>> {
>>> @Override
>>> protected void onBeforeRender()
>>> {
>>> setOutputMarkupId(true);
>>> setMarkupId (getLocalizer().getString
>>> ("linkIdPrefix", LinkSelection.this,
>>> new PropertyModel (LinkSelection.this.bk,
>>> "id")));
>>> add (new SimpleAttributeModifier
>>> ("onclick", getLocalizer().getString
>>> ("onclick", LinkSelection.this,
>>> new PropertyModel (LinkSelection.this.bk, "id"))));
>>> super.onBeforeRender();
>>> }
>>> };
>>> item.add (editLink);
>>> ...
>>>
>>> ERROR 29 11:58:24.086 Error attaching this container for rendering:
>>> [MarkupContainer [Component id = 0]] [o.a.w.RequestCycle]
>>> org.apache.wicket.WicketRuntimeException: Error attaching this container
>>> for
>>> rendering: [MarkupContainer [Component id = 0]]
>>> at
>>> org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1717)
>>> at org.apache.wicket.Component.onBeforeRender(Component.java:3757)
>>>
>>>
>>>
>>> igor.vaynberg wrote:
>>>>
>>>> set it in onbeforerender
>>>>
>>>> -igor
>>>>
>>>> On Fri, Jun 26, 2009 at 2:03 PM, OjO<fa...@washington.edu> wrote:
>>>>>
>>>>> I am using the following:
>>>>> myCom.setMarkupId (getLocalizer().getString ("handle", MyPanel.this,
>>>>> new
>>>>> Model (handleId)));
>>>>>
>>>>> but still getting WARNing:
>>>>>
>>>>> 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.
>>>>>
>>>>> What would be the correct way to get a property resource when a String
>>>>> value
>>>>> is needed?
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/localizer-and-variables-tp16548684p24227247.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
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/localizer-and-variables-tp16548684p24259437.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
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/localizer-and-variables-tp16548684p24261681.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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: localizer and variables
Posted by OjO <fa...@washington.edu>.
Sorry, I did not mean to abuse them. I am seeking the right way of getting
String properties associated with a panel class. What do you mean by
"externalized"? What is "an external resource"?
igor.vaynberg wrote:
>
> the property files are made for i18n, you are really abusing them. if
> you want these things externalized then load them from an external
> resource yourself.
>
> -igor
>
> On Mon, Jun 29, 2009 at 12:14 PM, OjO<fa...@washington.edu> wrote:
>>
>> Here is another more complex case:
>>
>> LinkSelection.properties:
>> edit_label=Edit
>> done_label=Hide Edit...
>> linkId=toggle_link_{id}
>> onclick=toggleEdit('{id}'); return(false);
>> divId=toggle_div_{id}
>>
>> LinkSelection.java has the following in the constructor:
>> @Override
>> protected void populateItem(ListItem item) {
>>
>> bk = (BkItemI)item.getModelObject();
>>
>> // 1. the edit icon
>> Label editLink = new Label ("edit_item_link",
>> ( isEditBk(bk)
>> ? new ResourceModel ("done_label")
>> : new ResourceModel
>> ("edit_label")))
>> {
>> @Override
>> protected void onBeforeRender()
>> {
>> setOutputMarkupId(true);
>> setMarkupId (getLocalizer().getString
>> ("linkIdPrefix", LinkSelection.this,
>> new PropertyModel (LinkSelection.this.bk,
>> "id")));
>> add (new SimpleAttributeModifier
>> ("onclick", getLocalizer().getString
>> ("onclick", LinkSelection.this,
>> new PropertyModel (LinkSelection.this.bk, "id"))));
>> super.onBeforeRender();
>> }
>> };
>> item.add (editLink);
>> ...
>>
>> ERROR 29 11:58:24.086 Error attaching this container for rendering:
>> [MarkupContainer [Component id = 0]] [o.a.w.RequestCycle]
>> org.apache.wicket.WicketRuntimeException: Error attaching this container
>> for
>> rendering: [MarkupContainer [Component id = 0]]
>> at
>> org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1717)
>> at org.apache.wicket.Component.onBeforeRender(Component.java:3757)
>>
>>
>>
>> igor.vaynberg wrote:
>>>
>>> set it in onbeforerender
>>>
>>> -igor
>>>
>>> On Fri, Jun 26, 2009 at 2:03 PM, OjO<fa...@washington.edu> wrote:
>>>>
>>>> I am using the following:
>>>> myCom.setMarkupId (getLocalizer().getString ("handle", MyPanel.this,
>>>> new
>>>> Model (handleId)));
>>>>
>>>> but still getting WARNing:
>>>>
>>>> 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.
>>>>
>>>> What would be the correct way to get a property resource when a String
>>>> value
>>>> is needed?
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/localizer-and-variables-tp16548684p24227247.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
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/localizer-and-variables-tp16548684p24259437.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
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/localizer-and-variables-tp16548684p24261681.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: localizer and variables
Posted by Igor Vaynberg <ig...@gmail.com>.
the property files are made for i18n, you are really abusing them. if
you want these things externalized then load them from an external
resource yourself.
-igor
On Mon, Jun 29, 2009 at 12:14 PM, OjO<fa...@washington.edu> wrote:
>
> Here is another more complex case:
>
> LinkSelection.properties:
> edit_label=Edit
> done_label=Hide Edit...
> linkId=toggle_link_{id}
> onclick=toggleEdit('{id}'); return(false);
> divId=toggle_div_{id}
>
> LinkSelection.java has the following in the constructor:
> @Override
> protected void populateItem(ListItem item) {
>
> bk = (BkItemI)item.getModelObject();
>
> // 1. the edit icon
> Label editLink = new Label ("edit_item_link",
> ( isEditBk(bk)
> ? new ResourceModel ("done_label")
> : new ResourceModel ("edit_label")))
> {
> @Override
> protected void onBeforeRender()
> {
> setOutputMarkupId(true);
> setMarkupId (getLocalizer().getString
> ("linkIdPrefix", LinkSelection.this,
> new PropertyModel (LinkSelection.this.bk, "id")));
> add (new SimpleAttributeModifier
> ("onclick", getLocalizer().getString
> ("onclick", LinkSelection.this,
> new PropertyModel (LinkSelection.this.bk, "id"))));
> super.onBeforeRender();
> }
> };
> item.add (editLink);
> ...
>
> ERROR 29 11:58:24.086 Error attaching this container for rendering:
> [MarkupContainer [Component id = 0]] [o.a.w.RequestCycle]
> org.apache.wicket.WicketRuntimeException: Error attaching this container for
> rendering: [MarkupContainer [Component id = 0]]
> at
> org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1717)
> at org.apache.wicket.Component.onBeforeRender(Component.java:3757)
>
>
>
> igor.vaynberg wrote:
>>
>> set it in onbeforerender
>>
>> -igor
>>
>> On Fri, Jun 26, 2009 at 2:03 PM, OjO<fa...@washington.edu> wrote:
>>>
>>> I am using the following:
>>> myCom.setMarkupId (getLocalizer().getString ("handle", MyPanel.this, new
>>> Model (handleId)));
>>>
>>> but still getting WARNing:
>>>
>>> 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.
>>>
>>> What would be the correct way to get a property resource when a String
>>> value
>>> is needed?
>>> --
>>> View this message in context:
>>> http://www.nabble.com/localizer-and-variables-tp16548684p24227247.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
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/localizer-and-variables-tp16548684p24259437.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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: localizer and variables
Posted by OjO <fa...@washington.edu>.
Here is another more complex case:
LinkSelection.properties:
edit_label=Edit
done_label=Hide Edit...
linkId=toggle_link_{id}
onclick=toggleEdit('{id}'); return(false);
divId=toggle_div_{id}
LinkSelection.java has the following in the constructor:
@Override
protected void populateItem(ListItem item) {
bk = (BkItemI)item.getModelObject();
// 1. the edit icon
Label editLink = new Label ("edit_item_link",
( isEditBk(bk)
? new ResourceModel ("done_label")
: new ResourceModel ("edit_label")))
{
@Override
protected void onBeforeRender()
{
setOutputMarkupId(true);
setMarkupId (getLocalizer().getString
("linkIdPrefix", LinkSelection.this,
new PropertyModel (LinkSelection.this.bk, "id")));
add (new SimpleAttributeModifier
("onclick", getLocalizer().getString
("onclick", LinkSelection.this,
new PropertyModel (LinkSelection.this.bk, "id"))));
super.onBeforeRender();
}
};
item.add (editLink);
...
ERROR 29 11:58:24.086 Error attaching this container for rendering:
[MarkupContainer [Component id = 0]] [o.a.w.RequestCycle]
org.apache.wicket.WicketRuntimeException: Error attaching this container for
rendering: [MarkupContainer [Component id = 0]]
at
org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1717)
at org.apache.wicket.Component.onBeforeRender(Component.java:3757)
igor.vaynberg wrote:
>
> set it in onbeforerender
>
> -igor
>
> On Fri, Jun 26, 2009 at 2:03 PM, OjO<fa...@washington.edu> wrote:
>>
>> I am using the following:
>> myCom.setMarkupId (getLocalizer().getString ("handle", MyPanel.this, new
>> Model (handleId)));
>>
>> but still getting WARNing:
>>
>> 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.
>>
>> What would be the correct way to get a property resource when a String
>> value
>> is needed?
>> --
>> View this message in context:
>> http://www.nabble.com/localizer-and-variables-tp16548684p24227247.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
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/localizer-and-variables-tp16548684p24259437.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: localizer and variables
Posted by Igor Vaynberg <ig...@gmail.com>.
probably because you call getmarkupid() before you call setmarkupid() ?
-igor
On Mon, Jun 29, 2009 at 10:43 AM, OjO<fa...@washington.edu> wrote:
>
> This id is used for event handling. When I moved the setMarkupId statement
> into onBeforeRender method, the handler no longer work.
>
> myCom.setMarkupId (getLocalizer().getString ("handle", MyPanel.this, new
> Model (handleId)));
>
>
> igor.vaynberg wrote:
>>
>> set it in onbeforerender
>>
>> -igor
>>
>> On Fri, Jun 26, 2009 at 2:03 PM, OjO<fa...@washington.edu> wrote:
>>>
>>> I am using the following:
>>> myCom.setMarkupId (getLocalizer().getString ("handle", MyPanel.this, new
>>> Model (handleId)));
>>>
>>> but still getting WARNing:
>>>
>>> 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.
>>>
>>> What would be the correct way to get a property resource when a String
>>> value
>>> is needed?
>>> --
>>> View this message in context:
>>> http://www.nabble.com/localizer-and-variables-tp16548684p24227247.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
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
>
>
> --
> View this message in context: http://www.nabble.com/localizer-and-variables-tp16548684p24258625.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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: localizer and variables
Posted by OjO <fa...@washington.edu>.
This id is used for event handling. When I moved the setMarkupId statement
into onBeforeRender method, the handler no longer work.
myCom.setMarkupId (getLocalizer().getString ("handle", MyPanel.this, new
Model (handleId)));
igor.vaynberg wrote:
>
> set it in onbeforerender
>
> -igor
>
> On Fri, Jun 26, 2009 at 2:03 PM, OjO<fa...@washington.edu> wrote:
>>
>> I am using the following:
>> myCom.setMarkupId (getLocalizer().getString ("handle", MyPanel.this, new
>> Model (handleId)));
>>
>> but still getting WARNing:
>>
>> 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.
>>
>> What would be the correct way to get a property resource when a String
>> value
>> is needed?
>> --
>> View this message in context:
>> http://www.nabble.com/localizer-and-variables-tp16548684p24227247.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
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/localizer-and-variables-tp16548684p24258625.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: localizer and variables
Posted by OjO <fa...@washington.edu>.
Do you mean override the onbeforerender method of the current class or inside
the class of myCom object? Could you give an example?
> myCom.setMarkupId (getLocalizer().getString ("handle", MyPanel.this, new
> Model (handleId)));
igor.vaynberg wrote:
>
> set it in onbeforerender
>
> -igor
>
> On Fri, Jun 26, 2009 at 2:03 PM, OjO<fa...@washington.edu> wrote:
>>
>> I am using the following:
>> myCom.setMarkupId (getLocalizer().getString ("handle", MyPanel.this, new
>> Model (handleId)));
>>
>> but still getting WARNing:
>>
>> 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.
>>
>> What would be the correct way to get a property resource when a String
>> value
>> is needed?
>> --
>> View this message in context:
>> http://www.nabble.com/localizer-and-variables-tp16548684p24227247.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
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/localizer-and-variables-tp16548684p24227830.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: localizer and variables
Posted by Igor Vaynberg <ig...@gmail.com>.
set it in onbeforerender
-igor
On Fri, Jun 26, 2009 at 2:03 PM, OjO<fa...@washington.edu> wrote:
>
> I am using the following:
> myCom.setMarkupId (getLocalizer().getString ("handle", MyPanel.this, new
> Model (handleId)));
>
> but still getting WARNing:
>
> 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.
>
> What would be the correct way to get a property resource when a String value
> is needed?
> --
> View this message in context: http://www.nabble.com/localizer-and-variables-tp16548684p24227247.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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org