This really does save me quite a bit of code! Everywhere that I was saving off a FeedbackPanel field to my page/component so that I could later use it to add to an AjaxRequestTarget, GONE!
On Tue, Jul 20, 2010 at 1:49 PM, James Carman <ja...@carmanconsulting.com> wrote: > Here's the actual code (it works in our application)... > > �...@override > public AjaxRequestTarget newAjaxRequestTarget(Page page) > { > AjaxRequestTarget target = super.newAjaxRequestTarget(page); > target.addListener(new AjaxRequestTarget.IListener() > { > �...@override > public void onBeforeRespond(Map<String, Component> map, > final AjaxRequestTarget target) > { > if (!Session.get().getFeedbackMessages().isEmpty()) > { > target.getPage().visitChildren(IFeedback.class, > new Component.IVisitor<Component>() > { > public Object component(Component component) > { > if(component.getOutputMarkupId()) > { > target.addComponent(component); > } > return CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER; > } > }); > } > } > > �...@override > public void onAfterRespond(Map<String, Component> map, > AjaxRequestTarget.IJavascriptResponse response) > { > // Do nothing. > } > }); > return target; > } > > On Tue, Jul 20, 2010 at 11:47 AM, Igor Vaynberg <igor.vaynb...@gmail.com> > wrote: >> yes, you are on the right track. i just described this to someone in >> irc not a few days ago... >> >> override application.newajaxrequesttarget >> register your listener >> in listener onbeforerespond check if there are any messages - >> getsession().getfeedbackmessages().size()>0 >> visit all components in the page and look for IFeedback and add them >> to the target if they have setoutputmarkupid(true) - too late to force >> it to true at this point. >> >> -igor >> >> On Tue, Jul 20, 2010 at 8:34 AM, James Carman >> <ja...@carmanconsulting.com> wrote: >>> Perhaps we could just register a AjaxRequestTarget.IListener and >>> implement the onBeforeRespond() method? You would check to see if >>> there are any messages to be shown (still looking for how to ask that >>> question in the API). If there are, you'd make sure the requested >>> page's (requestTarget.getPage()) feedback panel component gets added >>> to the AjaxRequestTarget that's passed in. >>> >>> On Tue, Jul 20, 2010 at 11:23 AM, Igor Vaynberg <igor.vaynb...@gmail.com> >>> wrote: >>>> there is already IFeedback interface that tags all components like >>>> feedbackpanel. >>>> >>>> -igor >>>> >>>> On Tue, Jul 20, 2010 at 5:52 AM, James Carman >>>> <ja...@carmanconsulting.com> wrote: >>>>> I've struggled with this myself in the context of AJAX events that are >>>>> handled completely by subpanels. I want only one feedback panel on >>>>> the page, but the subpanels need to be able to add them to their >>>>> AjaxRequestTarget. Perhaps you could override the default ajax >>>>> request cycle handling in some way that looks at the page for an >>>>> interface (FeedbackContainer) or something. If there are any >>>>> messages, then it adds the feedback panel to the target automatically? >>>>> >>>>> On Tue, Jul 20, 2010 at 8:44 AM, Martin Makundi >>>>> <martin.maku...@koodaripalvelut.com> wrote: >>>>>> Hi! >>>>>> >>>>>> I don't like passing feedbackpanel to subpanels and I don't like the >>>>>> idea using visitors/component-search for looking it up in page >>>>>> hierarchy because of its potential volatility... >>>>>> >>>>>> Has some of you pals come up with a nice way of injecting >>>>>> feedbackpanel references to children or something? Or even better some >>>>>> direct refrence? Should I only allow one (particular) feedbackpanel >>>>>> per session and re-use it from session? >>>>>> >>>>>> ** >>>>>> Martin >>>>>> >>>>>> --------------------------------------------------------------------- >>>>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >>>>>> For additional commands, e-mail: users-h...@wicket.apache.org >>>>>> >>>>>> >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >>>>> For additional commands, e-mail: users-h...@wicket.apache.org >>>>> >>>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >>>> For additional commands, e-mail: users-h...@wicket.apache.org >>>> >>>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >>> For additional commands, e-mail: users-h...@wicket.apache.org >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org