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 > <[email protected]>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<[email protected]> 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<[email protected]> 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<[email protected]> 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: [email protected] >> >>>>> For additional commands, e-mail: [email protected] >> >>>>> >> >>>>> >> >>>> >> >>>> >> --------------------------------------------------------------------- >> >>>> To unsubscribe, e-mail: [email protected] >> >>>> For additional commands, e-mail: [email protected] >> >>>> >> >>>> >> >>>> >> >>> >> >>> -- >> >>> 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: [email protected] >> >>> For additional commands, e-mail: [email protected] >> >>> >> >>> >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: [email protected] >> >> For additional commands, e-mail: [email protected] >> >> >> >> >> >> >> > >> > -- >> > 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: [email protected] >> > For additional commands, e-mail: [email protected] >> > >> > >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > > -- 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: [email protected] For additional commands, e-mail: [email protected]
