It is possible to add feedback panel automatically by implementing org.apache.wicket.ajax.IListener
Here are are some examples: /** * TODO Suggest for jira addition, see * * http://apache-wicket.1842946.n4.nabble.com/HowTo-inject-FeedbackPanel-td2295430.html * * @author Martin * * Copyright (c) Koodaripalvelut.com Finland 2008 */ public static class TopMostVisibleFeedbackPanelAjaxAutoAdderListener implements IListener { private IFeedbackMessageFilter feedbackMessageFilter; /** * @see org.apache.wicket.ajax.AjaxRequestTarget.IListener#onBeforeRespond(java.util.Map, org.apache.wicket.ajax.AjaxRequestTarget) */ @Override public void onBeforeRespond(Map<String, Component> map, AjaxRequestTarget target) { FeedbackMessages feedbackMessages = Session.get().getFeedbackMessages(); List<FeedbackMessage> messages = feedbackMessages.messages(feedbackMessageFilter); if (!messages.isEmpty()) { Object feedbackPanel = null; for (FeedbackMessage feedbackMessage : messages) { Component component = feedbackMessage.getReporter(); if (component != null) { feedbackPanel = addFeedbackPanel(target, component); } } if (feedbackPanel == null) { // Some messages still want to become visible, try finding feedbackpanel from page addFeedbackPanel(target, target.getPage()); } } } /** * @param target * @param component * @return Object */ private Object addFeedbackPanel(AjaxRequestTarget target, Component component) { Object feedbackPanel = new VisitTopMostMarkupContainerPageOrModalWindowHavingVisibleChild(component, IFeedback.class).getFoundChild(); if (feedbackPanel instanceof Component) { if (!((Component) feedbackPanel).getOutputMarkupId()) { Utils.errorLog(TakpApplication.class, "Cannot update feedbackComponent that does not have setOutputMarkupId(" + component.getMarkupId() + ") property set to true. Component: " + component.getPageRelativePath() + ": " + component); } else { target.addComponent((Component) feedbackPanel); // Add feedbackPanel to the ajax request target return feedbackPanel; } } return null; } /** * @param feedbackMessageFilter the feedbackMessageFilter to set * @return NearestFeedbackPanelAjaxAutoAdderListener */ public TopMostVisibleFeedbackPanelAjaxAutoAdderListener setFeedbackMessageFilter(IFeedbackMessageFilter feedbackMessageFilter) { this.feedbackMessageFilter = feedbackMessageFilter; return this; } /** * @return the feedbackMessageFilter */ public IFeedbackMessageFilter getFeedbackMessageFilter() { return feedbackMessageFilter; } /** * @see org.apache.wicket.ajax.AjaxRequestTarget.IListener#onAfterRespond(java.util.Map, org.apache.wicket.ajax.AjaxRequestTarget.IJavascriptResponse) */ @Override public void onAfterRespond(Map<String, Component> map, org.apache.wicket.ajax.AjaxRequestTarget.IJavascriptResponse response) { // Override if necessary } } /** * @author Martin * * Copyright (c) Koodaripalvelut.com Finland 2008 */ public static class ErrorComponentAndNearestFeedbackPanelAjaxAutoAdderListener extends TopMostVisibleFeedbackPanelAjaxAutoAdderListener { /** * @see com.tustor.tuntinetti.view.TakpApplication.TopMostVisibleFeedbackPanelAjaxAutoAdderListener#onBeforeRespond(java.util.Map, org.apache.wicket.ajax.AjaxRequestTarget) */ @Override public void onBeforeRespond(Map<String, Component> map, AjaxRequestTarget target) { super.onBeforeRespond(map, target); WicketUtils.ajaxRefreshErrorComponents(target); } } /** * @param target */ public static void ajaxRefreshErrorComponents(AjaxRequestTarget target) { List<FeedbackMessage> feedbackMessages = Session.get().getFeedbackMessages().messages(new ErrorLevelFeedbackMessageFilter(FeedbackMessage.ERROR)); for (FeedbackMessage feedbackMessage : feedbackMessages) { if (feedbackMessage.getReporter() instanceof FormComponent) { if (feedbackMessage.getReporter().getOutputMarkupId()) { target.addComponent(feedbackMessage.getReporter()); } else { Utils.errorLog(WicketUtils.class, "Cannot update component that does not have setOutputMarkupId property set to true. Component: " + feedbackMessage.getReporter().getPageRelativePath()); } } } } 2013/5/16 Ernesto Reinaldo Barreiro <reier...@gmail.com>: > Paul, > > Maybe you might want use "AJAX event" to "automatically" add feedback to > target.... So, that you can safely forget;-) > > Cheers, > > Ernesto > > On Thu, May 16, 2013 at 12:30 AM, Paul Bors <p...@bors.ws> wrote: > >> Nevermind that... I forogt to add the feedback panel to the target :) >> >> ~ Thank you, >> Paul Bors >> >> >> On Wed, May 15, 2013 at 4:26 PM, Paul Bors <p...@bors.ws> wrote: >> >> > I'm a bit confused, how come if I call error() from inside by form button >> > and then refresh the feedback panel via ajax my error is not showing up? >> > >> > I always end up having to drop the error in the user's session. >> > >> > ~ Thank you, >> > Paul Bors >> > >> > > > > -- > Regards - Ernesto Reinaldo Barreiro --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org