html file which looks like this:
<wicket:panel>
<form wicket:id="adminUIForm">
<table wicket:id="datatable" class="datatable"></table>
<div wicket:id="institutTablePanel"></div>
</form>
</wicket:panel>
But in my Java Code I only want to instantiate the component institutTablePanel, when a row in the datatable is clicked, because the constructor looks like this:
target.add(new InstitutTablePanel("institutLabelPabel", selectedContact));
And selectedContact cannot be empty. Is there a possibility of doing this without getting an error that it cannot find the component in my JavaCode?
Edit: This might be helpful
@Override
protected Item<Kontakt> newRowItem(final String id, final int index,
final IModel<Kontakt> model) {
Item<Kontakt> rowItem = new Item<Kontakt>(id, index, model);
rowItem.add(new AjaxEventBehavior("onclick") {
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(AjaxRequestTarget target) {
selectedKontakt = model.getObject();
target.add(new InstitutTablePanel("institutTablePanel", selectedKontakt));
}
});
return rowItem;
}
Create an empty WebMarkupContainer
that is a blank div and add it to your page/parent component. Next, onClick
, use addOrReplace
and replace the the WebMarkupContainer
with the InstitutTablePanel
. Both the WebMarkupContainer
and the InstitutTablePanel
should have the same wicket:id