Hi,
I have a list view, and I am using LoadableDetachableModel as the
model for the list view.
The only problem that I have is I also have add more button, that adds
extra rows to the list view using ajax.
Since the model is read only, I can't add any rows to it.
WebMarkupContainer myPanel = new WebMarkupContainer(
"myPanel");
myPanel.setOutputMarkupId(true);
form.add(myPanel);
final ListView<Object> lv = new ListView<Object>("rows", (QueryModel)
getDefaultModel()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<Object> item)
{
Myrecord dR = (Myrecord) item.getModelObject();
item.add(new TextField<Integer>("value",
new PropertyModel<Integer>(dR, "value"),
Integer.class));
}
myPanel.add(lv);
AjaxSubmitLink addLink = new AjaxSubmitLink("addRow") {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(AjaxRequestTarget target, Form<?>
form)
{
if (count < 10)
{
lv.getModelObject().add(new Myrecord());
if (target != null)
{
target.addComponent(myPanel);
count++;
if (count >= 10)
{
addLink.setVisible(false);
target.addComponent(addLink);
}
}
}
}
};
addLink.setDefaultFormProcessing(false);
if (count >= 10)
addLink.setVisible(false);
form.add(addLink);
The QueryModel is a class extending LoadableDetachableModel
What other model can I use?
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]