1
public class engageLink extends AjaxLink{
private Engage engage;
private String name;
engageLink(String string, Engage anEngage,String name) {
super(string);
this.engage = anEngage;
this.name = name;
hasEngage=((Application) getApplication()).getVtb().hasEngagement(engage,name);
if(hasEngage)
this.add(new AttributeAppender("onclick", new Model("alert('This is my JS script');"), ";"));
}
boolean randevuAlmis;
@Override
public void onClick(AjaxRequestTarget target) {
if(hasEngage){
//do nothing or call ajax on failure script
} else{
((Application) getApplication()).getVtb().addEngagement(engage, name);
}
setResponsePage(new Sick(name));
}
@Override
protected org.apache.wicket.ajax.IAjaxCallDecorator getAjaxCallDecorator()
{
return new AjaxCallDecorator()
{
@Override
public CharSequence decorateOnSuccessScript(CharSequence script)
{
return "alert('Success');";
}
@Override
public CharSequence decorateOnFailureScript(CharSequence script)
{
return "alert('Failure');";
}
};
};
}
這是我的code.IN方法點擊我調用ajax onfailure腳本但它不起作用。如何在AjaxLink(Wicket)的onSubmit方法中調用Ajaxdecorator或javascript
我嘗試在構造函數中添加javascript,它不起作用。
問題是什麼。
請注意我打電話給ajaxdecorator像;
getAjaxCallDecorator().decorateOnFailureScript("some message");
我該如何解決這些問題。
謝謝
謝謝你,首先,他們不工作。後來我把setResponsePage行移入else語句中。結果非常好。非常感謝 – jacop41 2010-12-16 21:38:54