Hi!

We have created our own thing -- FeedbackLabel, which stands next to the
component inside of a form, and also works as a feedback. It takes
component to listen to as a constructor argument, and then just adds
appropriate class/title when there's something to show. For our app, if
something is wrong, label turns red and hovering it displays the error
text.

Then, for the case of Ajax Submit one would need to add all the feedback
labels to the AjaxRequestTarget. We do this with the FormComponentVisitor.

public class FeedbackLabel extends Label {
    @Override
    protected void onComponentTag(ComponentTag tag) {
        super.onComponentTag(tag);

        if (feedbackSource.getFeedbackMessage() == null) {
            return;
        }
        if (feedbackSource.getFeedbackMessage().isRendered()) {
            return;
        }
        FeedbackMessage fbMessage = feedbackSource.getFeedbackMessage();
        fbMessage.markRendered();

        if (feedbackSource.getFeedbackMessage().getMessage() == null) {
            LOGGER.warn("Unable to render component feedback message - it
is null! Component is "
                    + feedbackSource.getPath());
        }

        tag.put("title", fbMessage.getMessage().toString());
        tag.put("class", CSS_VALIDATION_ERROR_CLASS);
    }
}

br,
alex.

2012/5/14 Martin Grigorov <mgrigo...@apache.org>

> On Mon, May 14, 2012 at 10:36 AM, Chris Colman
> <chr...@stepaheadsoftware.com> wrote:
> > I added it inside the form in the markup and made sure I added the
> > FeedbackPanel to the form component itself and it appears to work quite
> > well.
> >
> > The wicket framework must have a flexible algorithm when looking for the
> > FeedbackPanel component to toggles it's visibility and add error
> > messages. I had previously always assumed that it only looked for the
> > FeedbackPanel in the parent of the form component.
>
> FeedbackPanel cares about this itself.
> Depending on the feedbackmessagefilter it decides whether there are
> any messages for it and changes its visibility.
> FeedbackPanel do not know anything about any Form component(s).
>
> >
> >
> >>-----Original Message-----
> >>From: Andrea Del Bene [mailto:adelb...@ciseonweb.it]
> >>Sent: Monday, 14 May 2012 6:22 PM
> >>To: users@wicket.apache.org
> >>Subject: Re: Feedback panel inside form
> >>
> >>Hi,
> >>
> >>it's absolutely ok to insert a feedback panel into its form.
> >>>
> >>> Every example of feedback panel I have seen places the feedback panel
> >>> outside the form element.
> >>>
> >>> I have some markup from a client that has some Javascript doing
> > client
> >>> side validation with a styled feedback panel (a div) inside the form
> >>> element itself.
> >>>
> >>> Is it only convention that sees most Wicket samples having the
> >>> feedback panel outside the form? i.e. can Wicket use a feedback panel
> >>> that is actually inside the form?
> >>>
> >>> Yours sincerely,
> >>>
> >>> Chris Colman
> >>>
> >>> Pagebloom Team Leader,
> >>>
> >>> Step Ahead Software
> >>>
> >>> pagebloom - your business & your website growing together
> >>>
> >>> Sydney:(+61 2) 9656 1278 Canberra: (+61 2) 6100 2120
> >>>
> >>> Email: chr...@stepahead.com.au <mailto://chr...@stepahead.com.au>
> >>>
> >>> Website:
> >>>
> >>> http://www.pagebloom.com <blocked::http://www.pagebloom.com/>
> >>>
> >>> http://develop.stepaheadsoftware.com
> >>> <blocked::http://develop.stepaheadsoftware.com/>
> >>>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Alexander Cherednichenko

[ the only way out is the way up ]

Reply via email to