Reputation: 31
I'm trying to disable an AjaxLink
button in wicket inside the
public void onClick(AjaxRequestTarget target)
method;
I tried calling the setEnabled(false)
directly but didn't work. some of the suggestions I saw online says call the isEnabled() or onConfigure()
methods; but these cannot be implemented inside the onclick
method; any help please?
{
buttonlabel.setDefaultModel(Model.of("Creating EWL"));
target.add(buttonlabel);
buttonlabel.setOutputMarkupPlaceholderTag(true);
boolean isWorkItemCreated = NewRecruitEWLUtil.createNewRecruitWorkItem(appInfo);
if (isWorkItemCreated)
{
buttonlabel.setDefaultModel(Model.of("EWL Created"));
target.add(buttonlabel);
buttonlabel.setOutputMarkupPlaceholderTag(true);
setEnabled(false);
target.add(this);
System.out.println("setEnabled ..." + isEnabled());
}
}
Upvotes: 0
Views: 368
Reputation: 17513
setEnabled(false)
is the correct way! You also need to add the AjaxLink to the AjaxRequestTarget so it is repaint at the browser:
AjaxLink link = new AjaxLink("myLink") {
@Override
public void onClick(AjaxRequestTarget target) {
setEnabled(false);
target.add(this);
}
};
add(link);
link.setOutputMarkupId(true);
Upvotes: 1