Hello Igor,

thanks for your reply!

But super.getOnClickScript() just returns null. Looking at Link's
code, I found out that the onClick code is created in method
onComponentTag(), and simply replaced by getOnClickScript() if that
doesn't return null.

But I found a solution:

protected CharSequence getOnClickScript(CharSequence url) {
  StringBuffer buf = new StringBuffer();
  buf.append("if (!window.confirm('Are you sure?')) return false;");
  buf.append("location.href='");
  buf.append(url);
  buf.append("';");
  return buf.toString();
}

The tricky part of generating the url is done already, and passed as
an argument. I already wondered before what url that might be, but it
turns out its just what I needed :)


-- 
greetings from Berlin,

Rüdiger Schulz

Igor Vaynberg wrote on 25.04.2006 at 20:00:

> protected String getOnClickScript() {
>   String wicketScript=super.getOnClickScript();
>   return "if (!alert('blah')) return false; "+wicketScript;
> }

> -Igor


> On 4/25/06, Rüdiger Schulz <[EMAIL PROTECTED]> wrote:
> Hello all,

> I want to use a <button> which is specified by a Link in java. This
> works fine, my onClik() method of the link is executed.

> Now I want to prepend a onClick-JavaScript, asking for confirmation
> via window.confirm(), and not executing the Wicket generated
> Javascript if cancel is clicked.

> My problem is, I don't get my JavaScript prepended.

> When I override getOnClickScript(), the Wicket-generated JS is
> discarded.

> When I use an (Simple)AttributeModifier or AttributeAppender, my
> JavaScript is put into another onClick attribute of the <button> tag,
> and it never gets executed.

> Is there a way to put my custom script before the Wicket script? Or
> should I simply look for another solution (like an image link
> or sth like that)?

> --
> greetings from Berlin,

> Rüdiger Schulz



> -------------------------------------------------------
> 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?cmdlnk kid0709 bid 3057 dat1642
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user












-------------------------------------------------------
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&kid0709&bid&3057&dat1642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to