Re: Add aria tag and css class to input on error

2017-03-10 Thread Entropy
That looks pretty darn perfect.  I'll try that.  Thanks!

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Add-aria-tag-and-css-class-to-input-on-error-tp4677286p4677288.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Add aria tag and css class to input on error

2017-03-10 Thread Martin Grigorov
Hi,

Here is a simple Behavior that adds "has-error" CSS class to any component
that has an error feedback message:

public class ErrorBehavior extends Behavior {

@Override
public void onComponentTag(Component component, ComponentTag tag) {
FeedbackCollector feedbackCollector = new
FeedbackCollector(component);
List feedbackMessageList =
feedbackCollector.collect(new
ErrorLevelFeedbackMessageFilter(FeedbackMessage.ERROR));
if (CollectionUtils.isNotEmpty(feedbackMessageList)) {
tag.append("class", "has-error", " ");
}
}
}

You can add it to all FormComponents with IComponentInstantiationListener:

public static class InstantiationListener implements
IComponentInstantiationListener {
@Override
public void onInstantiation(Component component)
{
if (component instanceof FormComponent)
{
component.add(new ErrorBehavior());
}
}
}

In YourApplication#init(): getComponentInstantiationListeners().add(new
InstantiationListener())


Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Fri, Mar 10, 2017 at 8:50 PM, Entropy  wrote:

> We need to add an aria tag to out input controls(and maybe a css class)
> whenever they have an error on that control.  Is there a way to make that
> happen automagically for a whole form, or would each valdator do it or
> what?
> How would one go about that in wicket?
>
> --
> View this message in context: http://apache-wicket.1842946.
> n4.nabble.com/Add-aria-tag-and-css-class-to-input-on-error-tp4677286.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Add aria tag and css class to input on error

2017-03-10 Thread Entropy
We need to add an aria tag to out input controls(and maybe a css class)
whenever they have an error on that control.  Is there a way to make that
happen automagically for a whole form, or would each valdator do it or what? 
How would one go about that in wicket?

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Add-aria-tag-and-css-class-to-input-on-error-tp4677286.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org