tags:

views:

31

answers:

2

I am new to wicket and trying to get some things working.
One thing that annoys me a lot is that I get a blank (0 chars of text) page whenever there is a syntax error on a page.

Striped down example:
Test.html

header stuff: doctype ... html ... head ... body ...
  <span wicket:id="msgTest" id="message">MSG</span>
footer stuff: /body ... /html

Test.java

public class Test extends WebPage {
    public Test() {
        add(new Label("msgTest", "Hello, World!"));
    }
}

This will output the page as expected.
Now, lets introduce an error:

header stuff: doctype ... html ... head ... body ...
  <span wicket:id="msgTest2" id="message">MSG</span>
footer stuff: /body ... /html

I changed the label-id to something different then what the source-file expects.
If I run this code I get the already mentioned blank page.
However, for every request to a page with such a syntax error I get an error report in the log-file of around 1000+ lines. This error-report is basically just wicket-generated html of a page which describes the error.
This makes me wonder why wicket isn't displaying the error-stuff instead of the blank page. I'm not very experienced with wicket but to me it somehow looks like wicket is having trouble rendering its own error-page code.

It would be nice to know how one goes about finding syntax-errors with wicket.
Reading through a 1000+ line error-report for a small error like a misplaced character seems a bit tedious.

Thanks in advance for guiding me into the right direction :)

PS:
wicket-version: 1.4.9
stage: development

A: 

What I like to do is write unit tests with WicketTester to at least verify that things render, and usually also write assertions to check the components. Something along the lines of

@Test
public void testMessageLabel(
    WicketTester tester = new WicketTester();
    tester.startPage(Test.class);
    tester.assertLastRenderedPage(Test.class);
    tester.assertComponent("msgTest", Label.class);
    tester.assertLabel("msgTest", "Hello, World!");
)

Then if as in your example the code contains "msgTest" and the html contains "msgTest2" you at least get a test failure instead of seeing it as part of a failing app after deploy.

It's certainly not a complete solution, since this error will make any rendering test for the page fail and the particular failure will just give a long error message in the test result, but at least you don't have to search log files.

Don Roby
A: 

I can not confirm that behavior. I went to http://wicket.apache.org/quickstart.html and created a quickstart. Changed the wicket id from 'message' to 'message1' and got a nice descriptive page in jetty:

WicketMessage: Unable to find component with id 'message' in [Page class = com.mycompany.HomePage, id = 0, version = 0]. This means that you declared wicket:id=message in your markup, but that you either did not add the component to your page at all, or that the hierarchy does not match.

How did you create your project?

bert
Yepp, found the problem. I have been using apache-ivy to resolve the projects dependencies. This will also fetch wicket-1.4.9-javadoc.jar. The Page which is used to render the error-report is present in both jars, but when the classloader searches for the file it will fetch the one from the javadoc jar. As a result of that rendering the error-page fails and I end uf with the blank page.I now "blacklisted" the javadoc.jar from beeing copied to the deployment directory, so that the correct error-page is being fetched.
Philipp