Here's a minimal example of my problem.
Again, the LDM::getObject() call AFTER the onSubmit()
call that changes the data does not result in a LDM::load().
There's a load() before the onSubmit(), but that's too early.
Anyone? What am I missing?
Thanks,
-troy
[jetty] DDC choices LDM: getObject
[jetty] DDC choices LDM: load(reading choices)
[jetty] DDC choices LDM: onAttach
[jetty] Form onSubmit
[jetty] DDC choices LDM: getObject
[jetty] DDC choices LDM: onDetach
[jetty]
<?xml version="1.0" encoding="UTF-8"?>
<html>
<head></head>
<body>
Pressing the button adds an entry to the drop down list,
but you can't see it without reloading the page.
<br/>
What am I missing?
<div style="position:relative; left:10px;">
<br/>
<form wicket:id="form" style="position:relative; left:10px;">
<select wicket:id="ddc"/>
<input type="submit" value="add an entry"/>
</form>
</div>
</body>
</html>
package dummy;
import java.util.*;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.*;
import org.apache.wicket.model.*;
public class Dummy extends WebPage
{
private static final long serialVersionUID = 1L;
private ArrayList<String> choices = new ArrayList<String>();
private Integer item = new Integer(1);
public Dummy(final PageParameters parameters)
{
super(parameters);
choices.add(item.toString());
IModel choicesModel = new LoadableDetachableModel() {
private static final long serialVersionUID = 1L;
@Override
protected void onAttach() {
System.out.println("DDC choices LDM: onAttach");
super.onAttach();
}
@Override
protected void onDetach() {
System.out.println("DDC choices LDM: onDetach\n");
super.onDetach();
}
@Override
public Object getObject() {
System.out.println("DDC choices LDM: getObject");
return super.getObject();
}
@Override
protected Object load() {
System.out.println("DDC choices LDM: load(reading
choices)");
// Note the clone() --
// to simulate a hibernate pull
return choices.clone();
}
};
final DropDownChoice ddc = new DropDownChoice("ddc",
new Model(), choicesModel);
Form form = new Form("form") {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit()
{
System.err.printf("Form onSubmit\n");
ddc.setModelObject(null);
choices.add((++item).toString());
}
};
add(form);
form.add(ddc);
}
}