Wicket 资源 - 未找到字符串?
我正在使用 wicket 的表单输入组件。我尝试将 enum
放入 DropDownMenu
:
public enum Choice { ONE, TWO, THREE }
cz.oz.wicket.pages.form.FormPage.java
--------------
.add( new DropDownChoice("choice",
Arrays.asList( Choice.values() ), new EnumChoiceRenderer() )
)
并添加了一个属性文件:
cz.oz.wicket.pages.form.FormPage.properties
--------------
Choice.ONE = Jedna
Choice.TWO = Dvě
Choice.THREE = Tři
根据我所读到的内容,它应该可以工作。
但我得到:
java.util.MissingResourceException: Unable to find property: 'Choice.ONE'
at org.apache.wicket.Localizer.getString(Localizer.java:344)
at org.apache.wicket.Localizer.getString(Localizer.java:100)
at org.apache.wicket.markup.html.form.EnumChoiceRenderer.getDisplayValue(EnumChoiceRenderer.java:82)
at org.apache.wicket.markup.html.form.EnumChoiceRenderer.getDisplayValue(EnumChoiceRenderer.java:39)
at org.apache.wicket.markup.html.form.AbstractChoice.appendOptionHtml(AbstractChoice.java:384)
at org.apache.wicket.markup.html.form.AbstractChoice.onComponentTagBody(AbstractChoice.java:361)
at org.apache.wicket.Component.renderComponent(Component.java:2619)
...
怎么了?
谢谢,
翁德拉
I'm playing with wicket's form input components. I tried to put an enum
to a DropDownMenu
:
public enum Choice { ONE, TWO, THREE }
cz.oz.wicket.pages.form.FormPage.java
--------------
.add( new DropDownChoice("choice",
Arrays.asList( Choice.values() ), new EnumChoiceRenderer() )
)
and added a properties file:
cz.oz.wicket.pages.form.FormPage.properties
--------------
Choice.ONE = Jedna
Choice.TWO = Dvě
Choice.THREE = Tři
According to what I've read, it should work.
But I get:
java.util.MissingResourceException: Unable to find property: 'Choice.ONE'
at org.apache.wicket.Localizer.getString(Localizer.java:344)
at org.apache.wicket.Localizer.getString(Localizer.java:100)
at org.apache.wicket.markup.html.form.EnumChoiceRenderer.getDisplayValue(EnumChoiceRenderer.java:82)
at org.apache.wicket.markup.html.form.EnumChoiceRenderer.getDisplayValue(EnumChoiceRenderer.java:39)
at org.apache.wicket.markup.html.form.AbstractChoice.appendOptionHtml(AbstractChoice.java:384)
at org.apache.wicket.markup.html.form.AbstractChoice.onComponentTagBody(AbstractChoice.java:361)
at org.apache.wicket.Component.renderComponent(Component.java:2619)
...
What's wrong?
Thanks,
Ondra
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
EnumChoiceRenderer 不知道在哪里查找属性文件。
您可以通过将页面添加为渲染器的构造函数参数来告诉它属性文件与页面关联:
The EnumChoiceRenderer doesn't know where to look for the properties file.
You can tell it that the properties file is associated with the page by adding the page as a constructor parameter for the renderer: