use of org.apache.wicket.feedback.FeedbackMessage in project webanno by webanno.
the class BootstrapFeedbackPanel method initCloseAll.
private void initCloseAll() {
WebMarkupContainer messagesContainer = (WebMarkupContainer) get("feedbackul");
WebMarkupContainer closeAll = new WebMarkupContainer("closeAll") {
private static final long serialVersionUID = -2488179250168075146L;
@Override
protected void onConfigure() {
super.onConfigure();
// If there is more than 1 sticky messages, then show the close-all button
int stickyMessages = 0;
for (FeedbackMessage msg : getCurrentMessages()) {
if (!(msg.isSuccess() || msg.isInfo())) {
stickyMessages++;
}
if (stickyMessages > 1) {
break;
}
}
setVisible(stickyMessages > 1);
}
};
messagesContainer.add(closeAll);
}
use of org.apache.wicket.feedback.FeedbackMessage in project wicket by apache.
the class BaseWicketTester method getMessages.
/**
* Retrieves <code>FeedbackMessages</code>.
*
* @param level
* level of feedback message, for example:
* <code>FeedbackMessage.DEBUG or FeedbackMessage.INFO.. etc</code>
* @return <code>List</code> of messages (as <code>String</code>s)
* @see FeedbackMessage
*/
public List<Serializable> getMessages(final int level) {
List<FeedbackMessage> messages = getFeedbackMessages(new ExactLevelFeedbackMessageFilter(level));
List<Serializable> actualMessages = Generics.newArrayList();
for (FeedbackMessage message : messages) {
actualMessages.add(message.getMessage());
}
return actualMessages;
}
use of org.apache.wicket.feedback.FeedbackMessage in project wicket by apache.
the class FormTesterTest method test_1.
/**
* @throws Exception
*/
@Test
public void test_1() throws Exception {
tester.startPage(EmailPage.class);
assertEquals(EmailPage.class, tester.getLastRenderedPage().getClass());
EmailPage page = (EmailPage) tester.getLastRenderedPage();
FormTester formTester = tester.newFormTester("form");
formTester.setValue("email", "a");
formTester.submit();
assertEquals(EmailPage.class, tester.getLastRenderedPage().getClass());
page = (EmailPage) tester.getLastRenderedPage();
assertNull(page.getEmail());
assertTrue(page.get("form:email").hasFeedbackMessage());
final List<FeedbackMessage> messages = page.get("form:email").getFeedbackMessages().toList();
assertEquals(1, messages.size());
assertEquals("wrong email address pattern for email", messages.get(0).getMessage().toString());
}
use of org.apache.wicket.feedback.FeedbackMessage in project wicket by apache.
the class WebPageRenderer method bindSessionIfNeeded.
/**
* Bind the session if there are feedback messages pending.
* https://issues.apache.org/jira/browse/WICKET-5165
*/
private void bindSessionIfNeeded() {
// check for session feedback messages only
FeedbackCollector collector = new FeedbackCollector();
List<FeedbackMessage> feedbackMessages = collector.collect();
if (feedbackMessages.size() > 0) {
Session.get().bind();
}
}
use of org.apache.wicket.feedback.FeedbackMessage in project wicket by apache.
the class FormGroup method onConfigure.
@Override
protected void onConfigure() {
super.onConfigure();
// set all components visible
help.setVisible(true);
label.setVisible(true);
feedback.setVisible(true);
// clear feedback message and current state
stateClassName = "";
feedback.setDefaultModelObject("");
final List<FormComponent<?>> formComponents = findFormComponents();
for (final FormComponent<?> fc : formComponents) {
final FeedbackMessages messages = fc.getFeedbackMessages();
if (!messages.isEmpty()) {
final FeedbackMessage worstMessage = getWorstMessage(messages);
worstMessage.markRendered();
feedback.setDefaultModelObject(worstMessage.getMessage());
// render worst message of first found child component with feedback message
break;
}
}
}
Aggregations