Wicket资源 - 找不到字符串?

时间:2010-07-11 18:47:21

标签: string drop-down-menu enums wicket resourcebundle

我正在玩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)
...

怎么了?

谢谢,
Ondra

1 个答案:

答案 0 :(得分:1)

EnumChoiceRenderer不知道在哪里查找属性文件。

您可以通过将页面添加为渲染器的构造函数参数来告诉它属性文件与页面相关联:

  cz.oz.wicket.pages.form.FormPage.java
  --------------
  .add( new DropDownChoice("choice",
     Arrays.asList( Choice.values() ), new EnumChoiceRenderer(this) )
   )