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.htmlheader 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&开发者_开发技巧lt;/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: developmentI 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?
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.
精彩评论