Thanks a bunch Igor. It works well. A couple minor changes needed for 1.2.x, but nothing to sweat about. Looking forward to 1.3.
Again, thanks. Darren H. On Thursday 09 August 2007 14:33, Igor Vaynberg wrote: > this is for 1.3, but it might work for 1.2.x also > > package com.tbs.webapp.util; > > import org.apache.wicket.Component; > import org.apache.wicket.behavior.AbstractBehavior; > import org.apache.wicket.markup.ComponentTag; > import org.apache.wicket.model.IComponentAssignedModel; > import org.apache.wicket.model.IModel; > import org.apache.wicket.model.Model; > > public class LinkConfirmation extends AbstractBehavior { > > private final IModel msg; > > public LinkConfirmation(String msg) { > this(new Model(msg)); > } > > public LinkConfirmation(IModel msg) { > this.msg = msg; > } > > @Override > public void onComponentTag(Component component, ComponentTag tag) { > super.onComponentTag(component, tag); > > String onclick = tag.getAttributes().getString("onclick"); > > IModel model = msg; > if (model instanceof IComponentAssignedModel) { > model = ((IComponentAssignedModel) > model).wrapOnAssignment(component); > } > > onclick = "if (!confirm('" + model.getObject().toString() + "')) > return false; " + onclick; > tag.getAttributes().put("onclick", onclick); > > model.detach(); > msg.detach(); > } > > } > -igor > > On 8/9/07, Darren Houston <[EMAIL PROTECTED]> wrote: > > Hello all, first time post. > > > > I used Wicket 0.9 for a large project awhile back. We have continued to > > upgrade Wicket with every new release, and we currently sit at 1.2.6. I > > haven't done much maintenance on my project because every Wicket upgrade > > has > > been smooth. > > > > One feature Wicket didn't have back then was a SubmitLink, so I built my > > own. > > Now with Wicket 1.2.6, my SubmitLink doesn't work but Wicket's SubmitLink > > works. Let me explain; > > > > I have a "dynamic" page which contains a form which may contain > > listviews with listviews with listviews (up to 3 deep). Users can add and > > delete listviews at any depth and modify data in the listviews. The add > > and delete > > links in each listview are SubmitLinks so data isn't lost when the page > > reloads. Here is the problem; > > > > Say I have listviews 1, 2 and 3. When I delete listview 1 with my > > SubmitLink > > and the page returns, listview 1 and 2 are still present, listview 3 is > > gone. > > The database says listview 1 is deleted. If I leave the page and come > > back (the model is reloaded), listview 1 is deleted and listview 2 and 3 > > are displayed. When I delete listview 1 with Wicket's SubmitLink and the > > page returns, listview 1 is gone and listview 2 and 3 are present. > > > > So, to test I coppied the source of Wicket's SubmitLink into my own > > SubmitLink > > class and tried it out. The same problem explained above occurs, even > > though > > the onclick output of my SubmitLink is exactly the same as the onclick > > output > > of Wicket's submit link (the rest of the html is exactly the same too). > > Strange. > > > > I would use Wicket's SubmitLink, except I need a confirmation dialog to > > popup > > to confirm a user's delete request. > > > > So, does anyone know how to easily modify Wicket's SubmitLink javascript > > so I > > can have my confirmation dialog? I could override getOnClickScript() and > > pass > > in a bunch of javascript, but I would rather somehow grab the onclick > > javascript from SubmitLink and append the confirm. > > > > Or..., any other ideas? > > > > Thanks for any help, > > > > Darren H. > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]