tags:

views:

233

answers:

3

Hi,

Just started playing around with, how is everyone linking up their component ids ?

So far the most frequent error I've got are mismatches in component ids. For example,

In the html

...
<span wicket:id="messageID">message will be here</span>
...

and on the Java side

...
add(new Label("messageID", "If you see this message wicket is properly configured and running"));
...

I'm running on a maven/IntelliJ setup if that helps. Thanks!

A: 

Good question, and I'll be watching for other answers.

The best advice I can give is to use tests to catch the problem early.

Write a unit test using WicketTester for each component you develop at least verifying that your component renders. This will catch such errors in a test rather than in the running app.

You can and of course should also test that your component contains all the right pieces, that navigation works properly, etc... But the basic render test will catch id mismatches.

Don Roby
+1  A: 

Since you are using IntelliJ you could use the WicketForge plugin which highlights IDs that that do not appear in Java code. Apart from that, i would suggest testing the components, missing IDs are easy to detect in tests.

bert
+3  A: 

every wicket page I have has at least one test

@Test
public void testPageRender() {
    WicketTester tester = new WicketTester();
    tester.startPage( MyPage.class );
    tester.assertNoErrors();
}
walnutmon