{
super(id);
setRenderBodyOnly(true);
WebMarkupContainer button;
if (Boolean.valueOf(ajaxFlag)) {
button = new AjaxSubmitLink("button", form) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form form)
{
BeanSubmitButton.this.onAction(target, form, bean);
updateFeedbackPanels(target); // see comments in function javadoc
}
@Override
protected void onError(AjaxRequestTarget target, Form form)
{
BeanSubmitButton.this.onError(target, form, bean);
updateFeedbackPanels(target); // see comments in function javadoc
}
@Override
protected IAjaxCallDecorator getAjaxCallDecorator()
{
return decorator;
}
@Override
protected void onComponentTag(ComponentTag tag)
{
super.onComponentTag(tag);
tag.put("class", (label instanceof Label ? "beanSubmitButton" : "beanSubmitImageButton") );
tag.put("href", "javascript:void(0)"); // don't do href="#"
}
};
}
else {
button = new SubmitLink("button", form) {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit()
{
BeanSubmitButton.this.onAction(null, getForm(), bean);
}
@Override
protected void onComponentTag(ComponentTag tag)
{
super.onComponentTag(tag);
tag.put("class", (label instanceof Label ? "beanSubmitButton" : "beanSubmitImageButton") );
}
};
}
if (confirmMsg != null) {
button.add( new AttributeModifier("onclick", true, null) {
private static final long serialVersionUID = 1L;
@Override
protected String newValue(String currentValue, String replacementValue)
{
return "if (!confirm('" + confirmMsg + "')) return false; else { " + currentValue + " }";
}
});
}
if (Boolean.valueOf(isDefault)) {
button.add( new SimpleAttributeModifier("id", "bfDefaultButton") );
}
button.setOutputMarkupId(true);
add(button);
button.add(label);
}