0

I have one Wicket (6.19) bundle including:

  • HomePage.java
  • HomePage.html
  • HomePage.properties.xml

In the .java file I have this code :

public class HomePage extends BasePage {
    public HomePage() {
        add(new Label("message", getString("greetingMessage")));
    }
}

and in the .properties file I have this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM
    "http://www.oracle.com/webfolder/technetwork/jsc/dtd/properties.dtd">
<properties>
    <entry key="greetingMessage">Hello</entry>
</properties>

The problem is that calling the getString method returns an exception :

java.util.MissingResourceException: Unable to find property: 'greetingMessage' for component: [class=com.mycompany.HomePage]. Locale: null, style: null

What am i doing wrong ?

Sean Mickey
  • 7,618
  • 2
  • 32
  • 58

3 Answers3

1

Check your console:

WARN - PropertiesFactory - Unable to find resource file:/.../HomePage.properties.xml
java.util.InvalidPropertiesFormatException: org.xml.sax.SAXException: Invalid system identifier: http://www.oracle.com/webfolder/technetwork/jsc/dtd/properties.dtd

So replace the doctype declaration:

<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
svenmeier
  • 5,681
  • 17
  • 22
0

Better use add(new Label("message", new ResourceModel("greetingMessage")));.

Also make sure the .properties.xml file is copied by your build tool to HomePage.class, so it is available later at runtime.

martin-g
  • 17,243
  • 2
  • 23
  • 35
0

try

new Label("message", new StringResourceModel("greetingMessage", this, null).getString());
user1328889
  • 165
  • 1
  • 3
  • 9