Wicket 资源 - 未找到字符串?

发布于 2024-09-09 04:16:17 字数 1239 浏览 6 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等往事风中吹 2024-09-16 04:16:17

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

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

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

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:

  cz.oz.wicket.pages.form.FormPage.java
  --------------
  .add( new DropDownChoice("choice",
     Arrays.asList( Choice.values() ), new EnumChoiceRenderer(this) )
   )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文