Hello,
I think your problem is in how you define the search criteria pojo model:
final IModel addContactInfoModel = new
LoadableDetachableModel() {
protected Object load() {
ContactInfoPOJO modelObject = new
ContactInfoPOJO();
return modelObject;
}
};
The problem is that load() is going to be called during each request response sequence and by its definition
resetting the backing object to a newly instantiated instance each time the page is loaded.
Using final Model addContactInfoModel = new Model (new ContactInfoPOJO());
should solve your problems.
You should also consider using a DataTable for showing the results as it is
backed by a repeater and has built in support for paging, sorting, etc.
Mike
I need help regarding a simple use case.
I have a BasePage that has Two Panels : Top Panel and Bottom Panel
User Can enter search criteria in top Panel and Results need to be displayed
in Bottom Panel. Results displayed in ListView/DataView
#html looks like this...
<div wicket:id="topPanel">[Top panel]</div>
<div wicket:id="BottomPanel">[Bottom panel]</div>
#TopPanel
<form wicket:id="searchForm" >
// Lots of Search Fields....
// Submit Button
</form>
#BottomPanel
<divwicket:id="table">[ListView]</div>
How do I pass the search Criteria(a POJO) of Top Panel when user Submits the
Form to Bottom Panel?
Or,
If I use a webmarkup container for the search results....and use only one
panel(i.e the top panel) for search AND display...then how do i update the
Model for ListView? I tried all possible combinations...but failed...am I
missing something.
I was trying the use case that When user loads up the form first time the
fields of Search form are empty so ListView/dataview has no results.
When user enters some search criteria and clicks "Search" the web markup
container below updates its Model and displays the results according to
updated model....if there are no results then nothing gets displayed.
final WebMarkupContainer contactsWrapper = new
WebMarkupContainer(
"contactsWrap");
form.add(new AjaxButton("searchContacts") {
protected void onSubmit(AjaxRequestTarget target, Form
f) {
final ContactInfoPOJO c = (ContactInfoPOJO)
getForm().getModelObject();
IModel newModel = new LoadableDetachableModel()
{
protected Object load() {
return
WicketApplication.get().getContactInfoDao().getContactsBySearch(c);
}
};
// If javascript is enabled on user's browser.
if (target != null) {
// refresh the component.
target.addComponent(contactsWrapper);
}
}
});
Here the problem is that Model cannot be updated??
final ListView contacts = new ListView("viewContacts",
contactInfoModel) {
protected void populateItem(final ListItem item) {
item.add(new Label("fName", new
PropertyModel(item.getModel(),
"firstName")));
item.add(new Label("lName", new
PropertyModel(item.getModel(),
"lastName")));
}
}
contactsWrapper.add(contacts);
I have also attached the sample source files. Please help me .
Thanks
http://www.nabble.com/file/p18413133/SaveAndDisplayAjax.html
SaveAndDisplayAjax.html
http://www.nabble.com/file/p18413133/SaveAndDisplayAjax.java
SaveAndDisplayAjax.java
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]