API / Apache Wicket Interview questions
How do you troubleshoot a WicketRuntimeException about a missing wicket:id?
This exception fires when Wicket walks the HTML template during rendering and finds a tag carrying a wicket:id that has no matching component added in the Java code (or vice versa) — it's one of the most common first errors a Wicket developer hits.
- Read the exception message carefully — it names the exact
wicket:idvalue and the markup file/line where it couldn't be resolved, which is almost always enough to jump straight to the problem tag. - Check for a typo mismatch between the string passed to
add(new Label("username", ...))in Java and thewicket:id="username"attribute value in HTML — the single most frequent cause. - Confirm the component was actually added to the right parent — a component built but never passed to
add()(or added to the wrong container) leaves its markup tag unresolved. - Check sibling scope — a
wicket:idnested inside a Panel or Fragment's markup needs its component added to that Panel/Fragment instance, not to the outer Page, since resolution is scoped to the immediate parent container.
Because the exception message is unusually specific compared to many Java runtime errors, this is one case where reading the actual stack trace text carefully solves the problem faster than guessing.
More Related questions...