Hi Matt,

Assuming you refer to different error states like shown on
http://twitter.github.com/bootstrap/base-css.html#inputWarning , I think
that this is a problem you cannot easily solve within Stripes. In
contrast to JSF or other Java web frameworks, Stripes does not provide
different validation states. The whole validation mechanism is based on
just one implicit state: Error. Introduction of new states would require
rewriting some core classes of Stripes.

In case that you "just" want to use the error class in the appropiate
(outer) HTML tags, I think you will need custom JSP tags which allow you
to render the HTML in a Bootstrap compatible way - including any needed
error classes on the different HTML tags. Instead of <sd:text...> you
could then use something like <bs:text...> which would render the outer
div, label, input and span, depending on the error state of the input.
But I fear that you will have a lot of implementation work as this
affects all Stripes tags that can have an error state.

Probably the easiest solution for the "outer div gets extra class"
problem would be using JavaScript because it gives you full control over
the whole DOM. Just render the whole block in a way that it is
compatible with Bootstrap's CSS. After a form submit, just check any
input fields for the existance of the error class and then modify the
outer div class that belong to the input tag. I must admit that I would
generally prefer a Stripes solution, but probably this is the fastest to
implement solution which should solve the problem.

Kind regards,
Marcus


Am 28.12.2012 01:33, schrieb Matt White:
> Hi Y'all -
>
> I am converting some old code from HTML4 to HTML5 to get better mobile 
> support. So far things have been pretty smooth sailing - a testament to 
> how well Stripes was designed.
>
> I've been using the Twitter Bootstrap framework to make my job easier 
> since it handles a lot of the task of creating a responsive layout for 
> you. (See http://twitter.github.com/bootstrap/index.html) I've found 
> Stripes and Bootstrap to be a great combo since we've got the dynamic 
> attribute versions of the taglibs -- just pass the new HTML5 stuff off 
> as a dynamic attribute and away you go.
>
> There's one thing I'm trying to figure out how to do the best -- 
> field-level error handling.
>
> If you look at the "Validation states" part of the docs, located here:
> http://twitter.github.com/bootstrap/base-css.html#forms you can see that 
> Bootstrap brings with it a lot of nice things for showing field-level 
> validation errors.
>
> An example of a field with a validation error is:
>
> <div class="control-group warning">
>       <label class="control-label" for="inputWarning">Input with 
> warning</label>
>       <div class="controls">
>       <input type="text" id="inputWarning">
>       <span class="help-inline">Something may have gone wrong</span>
> </div>
>
>
> There's two things to note here:
> 1.) There's a span of type "help-inline" that you can append to fields 
> with errors. This is super simple to do with Stripes' built in 
> field-level validation today, it just goes in as an entry in the 
> StripesResources.properties file under stripes.fieldErrors.afterError.
>
> 2.) There's an extra class added to the outmost enclosing div (it goes 
> from "control-group" to "control-group warning"). This is the one I'm 
> trying to figure out how to light up the cleanest way possible.
>
>
> I've been trying to think of ways to get the extra class to appear in 
> that div and mostly coming up empty. The most obvious thing to do to me 
> is create a new tag that looks at the field errors to see if this field 
> is include and output "error" (or "warning", "info", "success") if 
> needed, but this seems kinda crude to me.
>
> Anyone have an idea on how to light up this functionality using Stripes?
>
> Thanks!
>
> - Matt
>
>


------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to