Search in sources :

Example 6 with FeedbackMessage

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);
}
Also used : FeedbackMessage(org.apache.wicket.feedback.FeedbackMessage) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 7 with FeedbackMessage

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;
}
Also used : Serializable(java.io.Serializable) FeedbackMessage(org.apache.wicket.feedback.FeedbackMessage) ExactLevelFeedbackMessageFilter(org.apache.wicket.feedback.ExactLevelFeedbackMessageFilter)

Example 8 with FeedbackMessage

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());
}
Also used : FormTester(org.apache.wicket.util.tester.FormTester) FeedbackMessage(org.apache.wicket.feedback.FeedbackMessage) Test(org.junit.Test)

Example 9 with FeedbackMessage

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();
    }
}
Also used : FeedbackCollector(org.apache.wicket.feedback.FeedbackCollector) FeedbackMessage(org.apache.wicket.feedback.FeedbackMessage)

Example 10 with FeedbackMessage

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;
        }
    }
}
Also used : FormComponent(org.apache.wicket.markup.html.form.FormComponent) FeedbackMessage(org.apache.wicket.feedback.FeedbackMessage) FeedbackMessages(org.apache.wicket.feedback.FeedbackMessages)

Aggregations

FeedbackMessage (org.apache.wicket.feedback.FeedbackMessage)14 Serializable (java.io.Serializable)4 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 FormComponent (org.apache.wicket.markup.html.form.FormComponent)3 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)2 Component (org.apache.wicket.Component)2 FeedbackMessages (org.apache.wicket.feedback.FeedbackMessages)2 IFeedbackMessageFilter (org.apache.wicket.feedback.IFeedbackMessageFilter)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 IModel (org.apache.wicket.model.IModel)2 OpResult (com.evolveum.midpoint.gui.api.component.result.OpResult)1 OperationResultPanel (com.evolveum.midpoint.gui.api.component.result.OperationResultPanel)1 ValidationErrorPanel (com.evolveum.midpoint.gui.api.component.result.ValidationErrorPanel)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)1 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)1 FeedbackAlerts (com.evolveum.midpoint.web.component.message.FeedbackAlerts)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AttributeModifier (org.apache.wicket.AttributeModifier)1