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
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user