The code below does what you ask: a link and any time the link is clicked a modal dialog is opened and the contents of the dialog are update via AJAX.
import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.AbstractReadOnlyModel; import org.odlabs.wiquery.ui.dialog.Dialog; /** * @author Ernesto Reinaldo Barreiro * */ public class DialogPanel extends Panel { private static final long serialVersionUID = 1L; private int counter = 0; private Dialog dialog; private Label content; /** * @param id */ public DialogPanel(String id) { super(id); AjaxLink<Void> openDialog = new AjaxLink<Void>("openDialog") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { counter++; target.addComponent(content); dialog.open(target); } }; add(openDialog); dialog = new Dialog("dialog"); dialog.setModal(true); dialog.setAutoOpen(false); add(dialog); add(dialog); content = new Label("content", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return "I have been openned " + counter + " times via AJAX!"; } }); content.setOutputMarkupId(true); dialog.add(content); } } ------------DialogPanel.html-------------- <html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"> <body> <wicket:panel> <div style="width: 100%; padding-top: 20px;"> <a wicket:id="openDialog">Click me to open dialog</a> <div wicket:id="dialog" title="Dialog"> <div wicket:id="content"></div> </div> </div> </wicket:panel> </body> </html> There is a wiQuery google group were you can ask such question as well. Ernesto On Sun, Oct 24, 2010 at 9:32 PM, drf <davidrfi...@gmail.com> wrote: > > The WiQuery home page gives a simple example of opening a jQuery dialog, > where the content already resides in the page. > > I wonder if anyone can provide code which shows how to use WiQuery to open a > JQuery dialog with dynamic content, presumably using Ajax. For instance, you > want to show an error message, but the error message cannot be known when > the page is built. From what I have seen on the forum, people have tried to > do this without success - but there must be a way. > > Any code/links/help is really appreciated! > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/WiQuery-Dialog-when-used-with-Ajax-tp3009441p3009441.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org