theonedev/onedev · error · org.apache.wicket.WicketRuntimeException
Could not find Form parent for {this}
Error message
Could not find Form parent for {this} What it means
FormComponent.getForm() throws WicketRuntimeException when Form.findForm(component) cannot locate an enclosing Form ancestor. Form components (text fields, checkboxes, buttons' processing) require a Form in their ancestry to participate in submission.
Source
Thrown at server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java:732
* input for this component instance.
*
* @param convertedInput
* the converted input
*/
public final void setConvertedInput(T convertedInput)
{
this.convertedInput = convertedInput;
}
/**
* @return The parent form for this form component
*/
public Form<?> getForm()
{
Form<?> form = Form.findForm(this);
if (form == null)
{
throw new WicketRuntimeException("Could not find Form parent for " + this);
}
return form;
}
/**
* Gets the request parameter for this component as a string.
*
* @return The value in the request for this component
*/
public String getInput()
{
String[] input = getInputAsArray();
if (input == null || input.length == 0)
{
return null;
}
elseView on GitHub (pinned to d44925c47c)
Solutions
- Wrap the component (or its panel) inside a Form in the hierarchy
- If using AjaxFallbackLink/panel outside forms, replace form components with plain links/models or add a Form
- Check Form.findForm semantics: the Form must be an ancestor; reorder the container hierarchy if it is a sibling
- For border/panel nesting, ensure the form encloses the panel's markup placement, not just its Java construction
Example fix
// before
add(emailField); // no form ancestor
// after
Form<Void> form = new Form<Void>("form");
form.add(emailField);
add(form); Defensive patterns
Strategy: validation
Validate before calling
boolean hasForm = Optional.ofNullable(component.getParent())
.map(p -> Form.findForm(component) != null).orElse(false); Try / catch
try {
Form<?> f = formComponent.getForm();
} catch (WicketRuntimeException e) {
throw new IllegalStateException("Place " + formComponent.getId() + " inside a Form");
} Prevention
- Always construct input components inside a Form subtree
- When re-parenting dynamically, verify a Form ancestor exists afterwards
- Panels with form controls must be added inside a Form on the host page
When it happens
Trigger: Adding a TextField/required FormComponent to a container that is not inside any Form; component reparented outside the form at runtime; using form components inside panels added to a page without a Form.
Common situations: Building reusable panels containing input fields and forgetting the host page to wrap them in a Form; moving a component between containers dynamically; nesting panels where the Form is a sibling rather than an ancestor.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- has not been properly added. Something in the hierarchy of
- No Page found for component
- Tried to remove validator that was not previously added. Mak
- FormComponent has to be required when the type is primitive
- Page classes should extend from BasePage.
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/556e612dad108e90.
Report an issue: GitHub.