org.uqbar.wicket.xtend.XButton Maven / Gradle / Ivy
package org.uqbar.wicket.xtend;
import org.apache.wicket.markup.html.form.Button;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure0;
import org.uqbar.commons.model.UserException;
/**
* xtend friendly wicket button.
* Allows you to use procedure's as onclick listeners.
*/
@SuppressWarnings("all")
public class XButton extends Button {
private Procedure0 procedure;
public XButton(final String id) {
super(id);
}
public void onSubmit() {
try {
this.procedure.apply();
} catch (final Throwable _t) {
if (_t instanceof UserException) {
final UserException e = (UserException)_t;
String _message = e.getMessage();
this.error(_message);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
public XButton setOnClick(final Procedure0 procedure) {
XButton _xblockexpression = null;
{
this.procedure = procedure;
_xblockexpression = this;
}
return _xblockexpression;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy