[ 
https://issues.apache.org/jira/browse/WICKET-4167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13135326#comment-13135326
 ] 

Peter Ertl commented on WICKET-4167:
------------------------------------

I would recommend that you provide a custom choice renderer in that case (based 
on your quickstart):

...

                IChoiceRenderer<String> renderer = new IChoiceRenderer<String>()
                {
                        public Object getDisplayValue(String id)
                        {
                                return getLocalizer().getString("myPrefix" + 
id, BadPage.this);
                        }

                        public String getIdValue(String object, int index)
                        {
                                return object;
                        }
                };
                DropDownChoice testSelect = new DropDownChoice("testSelect", 
Model.of(""), Arrays.asList("0", "1"), renderer);

...

the properties would be:

myPrefix0=bad
myPrefix1=good


                
> WebMarkupContainer breaks message-lookup  algorithm  
> -----------------------------------------------------
>
>                 Key: WICKET-4167
>                 URL: https://issues.apache.org/jira/browse/WICKET-4167
>             Project: Wicket
>          Issue Type: Bug
>    Affects Versions: 1.5.2
>            Reporter: Andrea Del Bene
>            Assignee: Peter Ertl
>            Priority: Minor
>         Attachments: QuickStart.zip
>
>
> I've got a little problem with message lookup. The case is the following:
> I've got a simple DropDownChoice (wicket id = testSelect) with some values, 
> let's say "0" and "1". I want to localize these value in order to display 
> "Sorry, it's bad" for zero and "Ok, its good!" for one. Since I want to reuse 
> these bundle in other components and I don't want to insert them into 
> Application.properties, the natural choice is to  create a package.properties 
> file inside common package of my application components. The bundles are the 
> following:
> testSelect.0=Sorry, it's bad
> testSelect.1=Ok, its good!
> Ok, everything works fine for my testSelect and wicket supports this kind of 
> customization. The problem arise when I decide to not add testSelect directly 
> to my page but instead to add it to a WebMarkupContainer which groups other 
> form components.
> Unfortunately now testSelect localization stops working. Since 
> WebMarkupContainer is not inside my application components package, now  
> PackageStringResourceLoader search the right key (ex: testSelect.0) in the 
> wrong package (i.e. org.apache.wicket.markup.html).
> Is this a known issue? Can we modify PackageStringResourceLoader in order to 
> extend key search across all loaded bundles (or at least across all parents 
> bundles)? Any other idea?
> PS: an obvious workaround is to create a subclass of WebMarkupContainer in 
> our custom package.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to