Is it possible generate 'bootstrap/foundation' constructions like that? And error fields 'exclusion' ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Is it possible generate 'bootstrap/foundation' constructions like that? And error fields 'exclusion' ?

blandger
This post was updated on .
Hi all.

1.
I'm curious if there is a way to generate error/alert/success messages like:
<div class="alert">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <strong>Warning!</strong> Best check yo self, you're not looking too good.
</div>

OR simpler

<div class="alert">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
</div>

As I think usually we use construction for errors/messages like:
            <span th:if="${#fields.hasErrors('*')}">
                <div class="alert alert-error" th:each="err : ${#fields.errors('*')}" th:text="${err}">Incorrect input</div>
            </span>
AND
            <div th:if="${message}" class="alert alert-success" th:text="${message}">Success</div>

but is it possible to make more complex constructions? Something like:
<span th:if="${#fields.hasErrors('*')}">
                <div class="alert alert-error" th:each="err : ${#fields.errors('*')}" th:text="... ??? button tag with ${err}... close button... ???">Incorrect input</div>
            </span>

2.
Is there work around/approach for 'excluding' some error fields from th:each="err : ${#fields.errors('*')} ?

Say I want some error messages to be visible near the <label>...<input...> inside FORM using:
                    <span th:if="${#fields.hasErrors('name')}" class="label label-important" th:errors="*{name}">
                        Incorrect User Name
                    </span>
                    <input id="name" type="text" name="name" maxlength="25" class="input-xlarge"
                           th:field="*{name}"
                           th:class="${#fields.hasErrors('name')}? 'fieldError input-xlarge' : 'input-xlarge'"/>

and I don't want them to be 'duplicated' in place:
<div class="alert alert-error" th:each="err : ${#fields.errors('*')}" th:text="${err}">
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible generate 'bootstrap/foundation' constructions like that? And error fields 'exclusion' ?

Emanuel
Administrator
I'm having trouble understanding your questions, but for #1, are you asking if it's possible to construct HTML tags by using Thymeleaf processors?  If that is your question, then I don't think you can do that with the standard Thymeleaf processors.  You can create a new dialect (ie: your own processors) that can do that sort of thing though.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible generate 'bootstrap/foundation' constructions like that? And error fields 'exclusion' ?

blandger
Emanuel,
In #1 I asked If is is possible to make 'complex' construction for displaying error/message.

Something like:
<div th:inline="text" th:if="${successMessage}" class="alert alert-success">
   <button type="button" class="close" data-dismiss="alert">&times;</button>
   [[${successMessage}]]!
</div>
I think that should work, although I didn't test it yet. I'll try later and post result.