You can control the look of the errors component using CSS. I also use
a component that extends Errors so that it can render outside of the
form:
public class FormErrors extends Errors {
@Parameter(required = true)
private Form _form;
@Inject
private Environment _environment;
void setupRender() {
final ValidationTracker tracker = _form.getDefaultTracker();
_environment.push(ValidationTracker.class, tracker);
}
boolean beforeRenderTemplate() {
return false; // don't render the body
}
void cleanupRender() {
_environment.pop(ValidationTracker.class);
}
}
If you are looking to get the error bubble to pop up after you submit
the form you could use this:
public class BubbleValidationDecorator extends BaseValidationDecorator {
private final Environment _environment;
private final RenderSupport _renderSupport;
public BubbleValidationDecorator(Environment environment,
RenderSupport renderSupport) {
_environment = environment;
_renderSupport = renderSupport;
}
public void afterField(Field field) {
final ValidationTracker validationTracker =
_environment.peekRequired(ValidationTracker.class);
if (validationTracker.inError(field)) {
_renderSupport.addScript(
"$('%s').getFieldEventManager().showValidationMessage('%s');",
field.getClientId(), validationTracker.getError(field));
}
}
}
Add to AppModule:
public static void contributeMarkupRenderer(
OrderedConfiguration<MarkupRendererFilter> configuration,
final Environment environment,
final RenderSupport support) {
MarkupRendererFilter validationDecorator = new MarkupRendererFilter() {
public void renderMarkup(MarkupWriter writer,
MarkupRenderer renderer) {
ValidationDecorator decorator = new
BubbleValidationDecorator(environment, support);
environment.push(ValidationDecorator.class, decorator);
renderer.renderMarkup(writer);
environment.pop(ValidationDecorator.class);
}
};
configuration.override("DefaultValidationDecorator",
validationDecorator);
}
On Wed, Aug 11, 2010 at 2:33 PM, Rich M <[email protected]> wrote:
> Hi,
>
> I've found resources that explain how to remove the validation bubbles, but
> I'm looking to display validation bubbles similar to how it's possible to
> record form errors to <t:errors/> after a 'failed' form submission.
>
> I have tight spacing in the UI layout and having to accommodate for the
> <t:errors/> isn't much of an option as it shifts the layout down and takes
> up valuable vertical space. The bubbles are really nice because they
> overlay!
>
> One note is that I've seen that it's possible to create customer validators
> (like 'letters' from the jumpstart demo) but my validation is server-side
> not client side, as it compares a password with the confirmation password.
> So I'm trying to achieve this after the user has submitted the form to be
> sure they think the passwords are what they want.
>
> Thanks,
> Rich
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
--
--
http://www.bodylabgym.com - a private, by appointment only, one-on-one
health and fitness facility.
--
http://www.ectransition.com - Quality Electronic Cigarettes at a
reasonable price!
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]