Hi
I am having a problem that I hope someone can shed some light on.
On my main page, I have a panel that simply displays a list of users (using
a LinkedList as a model).
Next to the panel, there is a link to open my modal window that contains a
list of all my users. I am trying to implement a solution in which I can
click that "add" button next to each user in the Modal window and have it
populate the panel on the main page (without closing the window).
I have tried a number of solutions without any success so far.
My code looks something like this:
public class MainPage() {
private List<User> users = new LinkedList<User>();
MainPage() {
WebMarkupContainer wmc = new WebMarkupContainer("userPanelContainer");
wmc.setOutputMarkupId(true);
wmc.add(new UserPanel("userPanel", users)
...
}
}
I have set the model of my UserPanel to my linked list and wrapped it with a
WebMarkupContainer so that the panel can be easily replaced using AJAX.
I then create my modal window like this:
final ModalWindow userSelector = new ModalWindow("userSelector");
and
recipientSelector.setPageCreator(new ModalWindow.PageCreator() {
public Page createPage() {
return new RecipientSelectionWindow(MainPage.this.users,
MainPage.this.wmc);
}
});
The idea here being that I can add the user in my modal window to the
underlying LinkedList<User> and have a handle to the wmc for any AJAX
updates.
In my modal window, I have the following onClick() method for my "add" link:
public void onClick(AjaxRequestTarget target) {
User selected = (User)getModelObject();
userList.add(selected);
if (target != null) {
target.addComponent(markupContainer);
}
}
I thought that this approach should be OK, but if fails miserably. The panel
on the main page never updates. Even if I refresh the page manually (F5).
The funny thing is though, that if I look at the AJAX DEBUG window, the
response seems fine and the ID tags are all correct. I suspect that the AJAX
response is being applied to my Modal window rather than my main page.
If I use my debugger, I can see the underlying LinkedList<User> being
updated too, but che changes are never displayed.
I am quite new to wicket, so I expect that I am doing something really
daft... I just can't figure out what it is. I am also sure that my current
approach is not optimal. Any suggestions on the "correct" way to do this
will also be greatly appreciated.
--
View this message in context:
http://www.nabble.com/Updating-Main-Page-From-Modal-Using-AJAX-tp22441758p22441758.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]