use of org.apache.wicket.feedback.FeedbackMessage in project hale by halestudio.
the class FieldMessage method onBeforeRender.
/**
* @see Component#onBeforeRender()
*/
@Override
protected void onBeforeRender() {
super.onBeforeRender();
// collector.collect();
List<FeedbackMessage> msgs = formComponent.getFeedbackMessages().toList();
// only collect the last message (XXX correct like this?)
FeedbackMessage msg = (msgs.isEmpty()) ? (null) : (msgs.get(msgs.size() - 1));
if (msg != null) {
setDefaultModel(new Model<Serializable>(msg.getMessage()));
add(new AttributeModifier("class", new Model<String>(getCssClass(msg.getLevelAsString()))));
} else {
if (specialValidStyle && formComponent.isValid() && formComponent.checkRequired()) {
setDefaultModel(new Model<String>(""));
add(new AttributeModifier("class", new Model<String>(getValidCssClass())));
} else {
setDefaultModel(text);
add(new AttributeModifier("class", new Model<String>(getDefaultCssClass())));
}
}
}
use of org.apache.wicket.feedback.FeedbackMessage in project ocvn by devgateway.
the class FileInputBootstrapFormComponentWrapper method addFileUploadFeedbackComponent.
private void addFileUploadFeedbackComponent() {
fileUploadFeedback.setOutputMarkupId(true);
// show only the messages (fatal, success) generated by this component
fileUploadFeedback.setFilter(new IFeedbackMessageFilter() {
private static final long serialVersionUID = 1L;
@Override
public boolean accept(final FeedbackMessage message) {
final Component reporter = message.getReporter();
// for example errors like 'FIELD is required.'
if (message.getLevel() == FeedbackMessage.ERROR) {
return false;
}
return reporter != null && (FileInputBootstrapFormComponentWrapper.this.contains(reporter, true) || Objects.equal(FileInputBootstrapFormComponentWrapper.this, reporter));
}
});
add(fileUploadFeedback);
}
use of org.apache.wicket.feedback.FeedbackMessage in project wicket by apache.
the class WicketTester method assertFeedback.
/**
* Assert that a particular feedback panel is rendering certain messages.
*
* NOTE: this casts the component at the specified path to a {@link FeedbackPanel}, so it will
* not work with custom {@link IFeedback} implementations unless you are subclassing
* {@link FeedbackPanel}
*
* @param path
* path to the feedback panel
* @param messages
* messages expected to be rendered
*/
public void assertFeedback(String path, Serializable... messages) {
final FeedbackPanel fbp = (FeedbackPanel) getComponentFromLastRenderedPage(path);
final IModel<List<FeedbackMessage>> model = fbp.getFeedbackMessagesModel();
final List<FeedbackMessage> renderedMessages = model.getObject();
if (renderedMessages == null) {
fail(String.format("feedback panel at path [%s] returned null messages", path));
}
if (messages.length != renderedMessages.size()) {
fail(String.format("you expected '%d' messages for the feedback panel [%s], but there were actually '%d'", messages.length, path, renderedMessages.size()));
}
for (int i = 0; i < messages.length && i < renderedMessages.size(); i++) {
final Serializable expected = messages[i];
boolean found = false;
for (FeedbackMessage actual : renderedMessages) {
if (Objects.equal(expected, actual.getMessage())) {
found = true;
break;
}
}
if (!found) {
assertResult(Result.fail("Missing expected feedback message: " + expected));
}
}
}
use of org.apache.wicket.feedback.FeedbackMessage in project midpoint by Evolveum.
the class FeedbackListView method populateItem.
@Override
protected void populateItem(final ListItem<FeedbackMessage> item) {
final FeedbackMessage message = item.getModelObject();
if (message.getMessage() instanceof OpResult) {
final OpResult opResult = (OpResult) message.getMessage();
OperationResultPanel panel = new OperationResultPanel("message", Model.of(opResult)) {
private static final long serialVersionUID = 1L;
@Override
public void close(AjaxRequestTarget target) {
super.close(target);
message.markRendered();
}
protected void onAfterRender() {
opResult.setAlreadyShown(true);
super.onAfterRender();
}
};
panel.add(new VisibleBehaviour(() -> opResult != null && !opResult.isAlreadyShown()));
panel.setOutputMarkupId(true);
item.add(panel);
} else {
message.markRendered();
ValidationErrorPanel validationPanel = new ValidationErrorPanel("message", item.getModel()) {
private static final long serialVersionUID = 1L;
@Override
public void close(AjaxRequestTarget target) {
super.close(target);
message.markRendered();
}
};
validationPanel.setOutputMarkupId(true);
item.add(validationPanel);
}
}
use of org.apache.wicket.feedback.FeedbackMessage in project oc-explorer by devgateway.
the class FileInputBootstrapFormComponentWrapper method addFileUploadFeedbackComponent.
private void addFileUploadFeedbackComponent() {
fileUploadFeedback.setOutputMarkupId(true);
// show only the messages (fatal, success) generated by this component
fileUploadFeedback.setFilter(new IFeedbackMessageFilter() {
private static final long serialVersionUID = 1L;
@Override
public boolean accept(final FeedbackMessage message) {
final Component reporter = message.getReporter();
// for example errors like 'FIELD is required.'
if (message.getLevel() == FeedbackMessage.ERROR) {
return false;
}
return reporter != null && (FileInputBootstrapFormComponentWrapper.this.contains(reporter, true) || Objects.equal(FileInputBootstrapFormComponentWrapper.this, reporter));
}
});
add(fileUploadFeedback);
}
Aggregations