I am trying to move a form from an inner class that extends Form to a public
class. This is so that I can override the onSubmit() method of my form.
Below are my files.
When I add the form to a wicket page with
add(new TemplateEditForm("templateeditform", templatemodel));
and the corresponding html code
<form wicket:id="templateeditform">editform</form>
My wicket code doesn't pick the wicket:ids in the TemplateEditForm.html file
up
WicketMessage: The component(s) below failed to render. A common
problem is that you have added a component in code but forgot to
reference it in the markup (thus the component will never be
rendered).
1. [MarkupContainer [Component id = name]]
2. [MarkupContainer [Component id = version]]
3. [MarkupContainer [Component id = author]]
4. [MarkupContainer [Component id = active]]
5. [MarkupContainer [Component id = description]]
6. [MarkupContainer [Component id = textarea]]
7. [MarkupContainer [Component id = type]]
8. [MarkupContainer [Component id = submit]]
I am sure I am doing something stupid, but I cannot find the solution to
this. Any ideas?
=====
public class TemplateEditForm extends Form {
private TemplateWebModel templatemodel;
public TemplateEditForm(String id, TemplateWebModel templatemodel) {
super(id);
this.templatemodel = templatemodel;
setModel(new CompoundPropertyModel(templatemodel));
add(new RequiredTextField("name"));
add(new RequiredTextField("version", java.lang.Long.class));
add(new RequiredTextField("author"));
add(new CheckBox("active"));
add(new VariableTextFieldPanel("description", new PropertyModel(
templatemodel.getObject(), "description")));
DropDownChoice ddc = new DropDownChoice("type", Arrays
.asList(TemplateType.values()), new IChoiceRenderer() {
public Object getDisplayValue(Object object) {
return getString(object.toString());
}
public String getIdValue(Object object, int index) {
return object.toString();
}
});
ddc.setRequired(true);
add(ddc);
add(new Button("submit", new ResourceModel("submit")));
}
@Override
public void onSubmit() {
WicketApplication.get().getTemplateFactory().store(
templatemodel.getEntity());
setResponsePage(new TemplateListPage());
}
}
And the corresponding html code
=======
<wicket:extend>
<table>
<tr>
<td><wicket:message key="name" /></td>
<td><input wicket:id="name" /></td>
</tr>
<tr>
<td><wicket:message key="version" /></td>
<td><input wicket:id="version" /></td>
</tr>
<tr>
<td><wicket:message key="author" /></td>
<td><input wicket:id="author" /></td>
</tr>
<tr>
<td><wicket:message key="active" /></td>
<td><input type="checkbox" wicket:id="active" /></td>
</tr>
<tr>
<td><wicket:message key="description" /></td>
<td><span wicket:id="description"></span></td>
</tr>
<tr>
<td><wicket:message key="type" /></td>
<td><select wicket:id="type">
<option></option>
</select></td>
</tr>
<tr>
<td colspan="2"><input wicket:id="submit" type="submit"></td>
</tr>
</table>
</wicket:extend>