Hi Michael,
Thanks for your reply.
For the Ajax solution...In the files that I attached. What I am tring to
do is loading the model when the page loads up first time.
At this time the Pojo is empty so model has no values ,which means there is
nothing to iterate so list appears empty.
Now, my challenge is when user click the search button and tries to
search...then I have to get the Pojo and call DAO to get the results and
wrap the results in the same model(that I used while loading up the
page)...so that same model gets new values and then update the
ListView/DataView without the whole page refresh.
But, I am unable to assign the newly returned values by DAO to old model
because it says final variable cannot be referred from inside
Do you think my approach is correct towards the problem?
Any suggestions?
Thanks,
RG
Michael O'Cleirigh wrote:
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 resultsand 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 modelif 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