If you can use Ajax, you could even implement it more transparently.
In that case, make a panel for the normal display of the row, and a
panel that has the buttons. When the row is clicked, you do an ajax
roundtrip, and replace the display component with the buttons
component. And attached to these buttons are yet two other ajax round
trips, one for canceling that would redisplay the normal row, and the
other would delete the row and let the whole list component render
itself (be careful: don't re-render a lists with ajax directly, but
instead re-render the parent of the list.

Eelco


On 9/9/06, Pierre-Yves Saumont <[EMAIL PROTECTED]> wrote:
> Hi Eelco, thanks for you help.
>
> I tried the second solution, and it works fine for a simple confirm
> message before action is taken.
>
> However, my use case is a bit different since I wanted to use a
> confirmation process that is already implemented and implies rountriping
> between the client and the server. Basically, when the button is clicked
> on a row in a listview, the corresponding record is marked "to be
> deleted" and the component is redisplayed, this time with an additionnal
> div with two buttons (confirm - cancel). If the user click confirm, the
> record is deleted only if the delay was not more than a preconfigured value.
>
> What I wanted to do is replace the HTML div containing the two buttons
> with a simple confirm dialog (which allow for much easier modal behavior).
>
> I eventually found the following solution: I replaced the two buttons
> with two invisible links and I call there onClick even that way:
>
> <script type="text/javascript">
>    function confirmDelete(message) {
>      if (confirm(message)) {
>
> document.getElementById("rightColumn_pagePanel_dialogBoxReponses_tabs_panel_dialogBoxContent_confirmLink").onclick();
>      }
>      else {
>
> document.getElementById("rightColumn_pagePanel_dialogBoxReponses_tabs_panel_dialogBoxContent_cancelLink").onclick();
>      };
>    }
> </script>
>
> Pierre-Yves
>
> Eelco Hillenius a écrit :
> > On 9/9/06, Pierre-Yves Saumont <[EMAIL PROTECTED]> wrote:
> >> Hello,
> >>
> >> What is the best way to call a Wicket url from Javascript? Is it
> >> possible to have Wicket embed a link in a script? Or should I use a
> >> normal link, make it invisible an programmatically click on it from the
> >> script?
> >
> > Use an attribute modifier for normal links (Wicket 2.0 code btw):
> >
> >      final Link removeLink = new Link(item, "remove") {
> >        public void onClick() {
> >          ...
> >        }
> >      };
> >      removeLink.add(new SimpleAttributeModifier("onclick",
> >          "if(!confirm('remove discount for "
> >              + discount.getCheese().getName()
> >              + " ?')) return false;"));
> >
> > Or if you use ajax links, use a call decorator:
> >
> >    private class RemoveLink extends AjaxLink {
> >      private final Discount discount;
> >
> >      private RemoveLink(ListItem<Discount> item, String id) {
> >        super(item, id);
> >        this.discount = item.getModelObject();
> >      }
> >
> >      @Override
> >      public void onClick(AjaxRequestTarget target) {
> >        ...
> >      }
> >
> >      @Override
> >      protected IAjaxCallDecorator getAjaxCallDecorator() {
> >        return new AjaxCallDecorator() {
> >          @Override
> >          public CharSequence decorateScript(CharSequence script) {
> >            return "if(!confirm('remove discount for "
> >                + discount.getCheese().getName()
> >                + " ?')) return false;" + script;
> >          }
> >        };
> >      }
> >    }
> >
> >
> > Eelco
> >
> >
> >
>
>

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to