Summary: I have a DefaultDataTable that is embedded in a form. In the table
is a checkbox column that I setup using a panel inside the cell. That
works.
When run, the table displays fine. The model get method is accessed. When I
click on some of the checkboxes and click the submit button,
The model is not updated. The set method on the model is not accessed.
Here is my code.
Can someone please help me find the problem.
public class PanelCfgListComp extends SysAdminBasePanel implements
Serializable {
private DefaultDataTablePanelCfg dataTable;
private ListIColumnPanelCfg columns;
private ListPanelCfg modelList = new ArrayList();
private ISortableDataProviderPanelCfg dataProvider;
public PanelCfgListComp(String id) {
super(id);
dataProvider = new SortableDataProviderPanelCfg() {
@Override
public Iterator? extends PanelCfg iterator(int first, int
count) {
Iterator itr =
getGuiService().getPanelConfigServ().extractSubRange(Status.active, first,
count);
itr =
getGuiService().getPanelConfigServ().extractSubRange(Status.active, first,
count);
return itr;
}
@Override
public int size() {
return
getGuiService().getPanelConfigServ().getMatches(Status.active);
}
@Override
public IModelPanelCfg model(PanelCfg object) {
return new ModelPanelCfg(object);
}
};
columns = new ArrayListIColumnPanelCfg();
columns.add(new AbstractColumn(new ModelString(Selected) ) {
@Override
public void populateItem(Item cellItem, String componentId,
IModel rowModel) {
CheckBoxPanel selectedPanel = new
CheckBoxPanel(componentId, rowModel);
cellItem.add(selectedPanel);
}
});
columns.add(new PropertyColumn(new ModelString(
Id), id));
columns.add(
new PropertyColumn(new ModelString(
Class Name), canonicalClassName));
columns.add(
new PropertyColumn(new ModelString(
Short Name), shortName));
dataTable = new DefaultDataTablePanelCfg(dataTable,
getColumns(), getDataProvider(), 10);
dataTable.setItemReuseStrategy(new ReuseIfModelsEqualStrategy() );
add(dataTable);
}
/**
* @return the dataTable
*/
public DefaultDataTablePanelCfg getDataTable() {
return dataTable;
}
/**
* @param dataTable the dataTable to set
*/
public void setDataTable(DefaultDataTablePanelCfg dataTable) {
this.setDataTable(dataTable);
}
/**
* @return the columns
*/
public ListIColumnPanelCfg getColumns() {
return columns;
}
/**
* @param columns the columns to set
*/
public void setColumns(ListIColumnPanelCfg columns) {
this.setColumns(columns);
}
/**
* @return the dataProvider
*/
public ISortableDataProviderPanelCfg getDataProvider() {
return dataProvider;
}
/**
* @param dataProvider the dataProvider to set
*/
public void setDataProvider(ISortableDataProviderPanelCfg
dataProvider) {
this.setDataProvider(dataProvider);
}
/**
* @return the modelList
*/
public ListPanelCfg getModelList() {
return modelList;
}
/**
* @param modelList the modelList to set
*/
public void setModelList(ListPanelCfg modelList) {
this.modelList = modelList;
}
}
public class CheckBoxPanel extends Panel {
public CheckBoxPanel(String id, final IModelPanelCfg model) {
super(id, model);
final PanelCfg panelCfg = model.getObject();
add(new CheckBox(isSelected, new Model() {
@Override
public Boolean getObject() {
System.out.println(Im reading the object in checkbox Model);
System.out.println(in class = +
panelCfg.getCanonicalClassName() );
return panelCfg.isSelected();
}
@Override
public void setObject(Object choice) {
System.out.println(Im setting the object in checkBox model);
System.out.println(in class = +
panelCfg.getCanonicalClassName() );
panelCfg.setSelected((Boolean) choice);
}
}));
public class ListPanelCfgCp extends SysAdminBasePanel {
public ListPanelCfgCp() {
super();
}
public ListPanelCfgCp(String id) {
super(id);
final FeedbackPanel feedback = new FeedbackPanel(feedback);
//add(feedback);
InputForm inputForm = new InputForm(inputForm, feedback);
add(inputForm);
}
/** form for processing the input. */
private class InputForm extends Form {
private PanelCfgListComp panelCfgListComp;
public InputForm(String