Page 1 of 1

thymeleaf expression ${#fields.hasErrors('*')}

Posted: Fri May 09, 2014 6:11 am
by eimhee
file:entityForm.html

Code: Select all

<blc:form th:object="${entityForm}"
      method="POST"
      class="twelve columns custom entity-form"
      th:classappend="${(additionalClasses == null ? '' : additionalClasses + ' ')
        + (additionalControllerClasses == null ? '' : additionalControllerClasses)}"
      th:action="@{${currentUrl}}"
      th:with="renderTabs=${#lists.size(entityForm.tabs) > 1 or (showSingleTab != null and showSingleTab)}">
    
    
    <div class="errors" blc_admin:errors="*{*}" th:if="${#fields.hasErrors('*')}">
        <div class="tabError" th:each="tab : ${tabErrors.entrySet()}" th:inline="text">
            <b>[[#{__${tab.key}__}]]</b>
            <span class="fieldError error" th:each="field : ${tab.value.entrySet()}">
                [[#{__${field.key}__}]]: [[#{__${field.value}__}]]
            </span>
            <br />
        </div>
    </div>
   
</blc:form>   


Code: Select all

public class EntityForm {


    // This is used to data-bind when this entity form is submitted
    protected Map<String, Field> fields = null;
   
}

I don't understand ${#fields.hasErrors('*')},

I check entityform has a field fields, but it doesn't has method 'hasErrors',
how does it work? thanks.

Re: thymeleaf expression ${#fields.hasErrors('*')}

Posted: Fri May 09, 2014 12:18 pm
by phillipuniverse
That expression is actually a Thymeleaf Utility: http://www.thymeleaf.org/doc/html/Using ... ty-objects. The doc for this utility specifically is at http://www.thymeleaf.org/doc/html/Thyme ... eld-errors.