org.uqbar.wicket.xtend.XForm Maven / Gradle / Ivy
package org.uqbar.wicket.xtend;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.IFormSubmitter;
import org.apache.wicket.model.IModel;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.uqbar.commons.model.UserException;
/**
* Subclasses wicket's Form in order to correctly handle
* UserExceptions within setters.
*/
@SuppressWarnings("all")
public class XForm extends Form {
public XForm(final String id) {
super(id);
}
public XForm(final String id, final IModel model) {
super(id, model);
}
public void process(final IFormSubmitter submittingComponent) {
try {
super.process(submittingComponent);
} catch (final Throwable _t) {
if (_t instanceof WicketRuntimeException) {
final WicketRuntimeException e = (WicketRuntimeException)_t;
Throwable _cause = e.getCause();
if ((_cause instanceof UserException)) {
Throwable _cause_1 = e.getCause();
String _message = _cause_1.getMessage();
this.error(_message);
} else {
throw e;
}
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy