Hi Bertrand,
You can render into a hidden div, then use some JavaScript to move them
into view. Something like this which uses jQuery.
response.render(OnDomReadyHeaderItem.forScript("$('#hiddenfeedback
div').appendTo($('#visiblefeedback'));"));
That behavior doesn't seem exactly right though. If a form is
AJAX-submitted twice with the same error, do you really want to show the
error twice?
We just allow user-initiated AJAX requests to re-render/clear the feedback
panel. Generally the user is either re-submitting a form, or
navigating/panel-swapping away. In either case the old feedback isn't
relevant anymore. In the few places where we have AJAX polling, e.g.
through AjaxSelfUpdatingTimerBehavior, we set a RequestCycle-scoped flag in
onTimer() or whatever to indicate that the request wasn't user-initiated.
This suppresses the feedback panel from being rendered. It's not pretty,
but it's what we do. :) Fortunately this polling stuff is going away as we
move to Wicket-Atmosphere.
Dan
On Fri, Jul 19, 2013 at 7:25 AM, Bertrand Guay-Paquet <
[email protected]> wrote:
> Hello,
>
> I have a catch-all feedback panel which displays feedback messages at the
> top of my web pages. It slides-in the message boxes and adds a "close" link
> to each one.
>
> It also has an event handler which makes sure it redraws itself each time
> Wicket handles an ajax request:
>
> @Override
> public void onEvent(IEvent<?> a_event) {
> // This makes sure the panel always adds itself to the ajax
> response
> if (a_event.getPayload() instanceof AjaxRequestTarget) {
> ((AjaxRequestTarget) a_event.getPayload()).add(**this);
> }
> }
>
> This way, I don't have to add it explicitly to the request target each
> time a component adds a session message.
>
> After each request, the default behavior is to clear all rendered feedback
> messages from the session. My problem is that each time an ajax request is
> made, the currently displayed feedback message list is replaced by a new
> one. This removes any unclosed messages still present from the DOM.
>
> How can I tell Wicket ajax to append DOM elements to a parent instead of
> re-rendering the parent and its children? Is there another solution?
>
> Not clearing the messages from the session and displaying them again is
> not an option because the fade-in animation would be repeated.
>
> Regards,
> Bertrand
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail:
> users-unsubscribe@wicket.**apache.org<[email protected]>
> For additional commands, e-mail: [email protected]
>
>