Spring Web Flow – displaying your JSR-303 validation messages using FreeMarker

Instead of creating a custom validator in the traditional sense I’m relying on JSR-303 annotations to specify validation constraints, because, it is the future, and I shouldn’t have to do a load of coding to specify common validation requirements like an email address regular expression or a numeric value that is required to be within a defined range.

Using Spring web flow, I found that binding error messages weren’t available when I called “<@spring.showErrors ‘<br/>’/>” in my freemarker view (after I had bound the field I wanted to show errors for of course).

So where are my error messages?

It turns out that Spring Web Flow has a different way of providing the user with feedback messages. The Spring Web Flow reference documentation says: “Spring Web Flow’s MessageContext is an API for recording messages during the course of flow executions”.

The message context (with all your binding error messages in it) can be found here: flowRequestContext.messageContext. I’ve written a couple of macros to make retrieving error messages from this object a little easier:

<#--
 * Shows flow messages (which reside in flowRequestContext.messageContext)
 *
 * @param source Name of the field that caused the error
 * @param severity String representation of org.springframework.binding.message.Severity
 * @param separator the html tag or other character list that should be used to
 *    separate each option. Typically '<br>'.
 * @param classOrStyle either the name of a CSS class element (which is defined in
 *    the template or an external CSS file) or an inline style. If the value passed in here
 *    contains a colon (:) then a 'style=' attribute will be used, else a 'class=' attribute
 *    will be used.
 * @param tag The HTML tag to wrap the error in
-->
<#macro showFlowMessages source severity separator classOrStyle="" tag="">
  <#assign messages = flowRequestContext.messageContext.getMessagesBySource(source)/>
  <#if (messages?size > 0)>
    <#list messages as message>
      <#if message.severity?string == severity>
        <#if classOrStyle == "" && tag == "">
          ${message.getText()}
        <#else>
          <#if classOrStyle == "">
            <${tag}>${message.getText()}</${tag}>
          <#else>
            <#if tag == ""><#local tag = "span" /></#if>
            <#if classOrStyle?index_of(":") == -1><#local attr="class"><#else><#local attr="style"></#if>
            <${tag} ${attr}="${classOrStyle}">${message.getText()}</${tag}>
          </#if>
        </#if>
        <#if message_has_next>${separator}</#if>
      </#if>
    </#list>
  </#if>
</#macro>

<#--
 * Shows flow messages (which reside in flowRequestContext.messageContext) in an ordered or unordered list
 *
 * @param source Name of the field that caused the error
 * @param severity String representation of org.springframework.binding.message.Severity
 * @param classOrStyle either the name of a CSS class element (which is defined in
 *    the template or an external CSS file) or an inline style. If the value passed in here
 *    contains a colon (:) then a 'style=' attribute will be used, else a 'class=' attribute
 *    will be used.
 * @param ordered Whether or not the macro should output the list as an <ol> or <ul>
-->
<#macro showFlowMessagesList source severity classOrStyle="" ordered=false>
  <#local errorsList><@showFlowMessages source, severity, "", "", "li" /></#local>
  <#if errorsList?trim != "">
    <#if classOrStyle == "">
      <#local attr="">
    <#elseif classOrStyle?index_of(":") == -1>
      <#local attr=" class=" + classOrStyle>
    <#else>
      <#local attr=" style=" + classOrStyle>
    </#if>
    <#if ordered><ol${attr}><#else><ul${attr}></#if>
    ${errorsList}
    <#if ordered></ol><#else></ul></#if>
  </#if>
</#macro>

I’ve added these to my spring extensions, which you can download here: springx.ftl

26 thoughts on “Spring Web Flow – displaying your JSR-303 validation messages using FreeMarker

  1. Pretty great post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. In any case I’ll be subscribing in your rss feed and I am hoping you write again soon!

  2. buy priligy online usa ruagra azithromycin package insert dailymed More research is needed about how honey bees are exposed to pesticides outside the field in which they are placed

  3. In fact he can guess who erectile dysfunction angry it is without even thinking goril x male enhancement pills about it reddit where buy priligy

  4. 15 19 Because tamoxifen use is inconsistent in patients with DCIS a modified algorithm was developed before the clinical validation study to predict local recurrence risk regardless of subsequent tamoxifen administration using data from the National Surgical Adjuvant Breast and Bowel Project NSABP B 14 study and a case control study priligy in usa

  5. priligy fda approval Environment food and stress can alter our genetic expression so we can t just supplement our way out of what Dr

  6. He is suggesting prolia injection twice a year can priligy cure pe These results are promising in considering hormonal therapies as prevention for headache disorders in elderly women

  7. Goldfain D Lavergne A Galian A et al buy priligy pills At the same time Funko will also unveil for 15 Domo Гў BatmanГў Metallic a new and sleek look that will serve as a fun variant of the original Гў BatmanГў Domo and a great addition to Гў Dark KnightГў Domo

  8. Commonly reported adverse events associated with paroxetine overdosage include somnolence coma nausea tremor tachycardia confusion vomiting and dizziness where to buy cytotec without dr prescription

  9. Asking quuestions arre iin fact fastiduous tjing if youu aree noot undersanding something completely, except this article gives nice ubderstanding
    yet.

  10. Das minimiert Leerlauf und erhöht die Wahrscheinlichkeit, genau die
    gewünschte Spielart vorzufinden. Erwartbar sind tägliche Öffnungszeiten vom späten Nachmittag oder Abend
    bis in die Nachtstunden; Spieltische öffnen in der Regel
    nach den Automaten. In manchen Häusern sind zusätzlich French-Roulette-Tische mit
    Call-Bets (Annoncen) oder Varianten mit leicht abweichendem
    Setzspektrum zu finden. Wer spielt, sollte dies verantwortlich tun, Limits kennen und Angebote nur innerhalb der
    geltenden gesetzlichen Rahmenbedingungen nutzen.
    Poker ist spieler-gegen-Spieler; der Raum behält Rake, wodurch Spielauswahl, Positionsspiel und Disziplin zentral werden. So bleibt Glücksspiel Seefeld ein Teil eines breiteren Programms – ein Ansatz,
    der die Balance wahrt und die Gesamterfahrung abrundet.
    Mit der Bahn ist Seefeld in Tirol direkt angebunden; vom Bahnhof sind es
    nur wenige Gehminuten. Für Pokerturniere Seefeld ist die Voranmeldung praktisch Pflicht, für
    Roulette und Blackjack hilft es, Stoßzeiten zu meiden.
    Denn die Kleiderordnung wurde gerade in der jüngeren Vergangenheit angepasst
    und die Zügel gelockert, wofür es einige kritischen Bewertungen gab.

    Untergebracht in einem historisch-rustikalen Backsteinhaus aus dem Jahre 1906
    können Gambler seit 2010 in der Spielbank die volle Bandbreite an klassischen und modernen Glücksspielen erleben. Aber selbst wer ohne zu spielen einfach nur das
    besondere und traditionelle Casino-Flair in Bad Ems erleben will, ist herzlichst eingeladen und willkommen. Dafür trägt auch der Automatenbereich Sorge, der vom Klassischen Spiel abgetrennt ist und knapp 70 Glücksspielautomaten umfasst.

    Das spiegelt sich im überschaubaren Angebot an Casinospielen wider.

    References:
    https://online-spielhallen.de/arena-casino-cashback-dein-ratgeber-fur-ruckerstattungen/

  11. In der Welt des Online-Glücksspiels ist Seriosität von entscheidender Bedeutung.
    Die Spieleauswahl ist das Herzstück jedes Online Casinos
    Las Vegas. Online Casinos, die den Las Vegas-Stil nachahmen, streben danach, dieses Erbe fortzusetzen und Spielern eine ähnliche Auswahl und Qualität zu bieten.
    Das Nob Hill Casino wird auf dem ehemaligen Gelände von Frank Musso’s Restaurant und Joey’s New Yorker Nightclub und dem zukünftigen Gelände des Casino Royale eröffnet.
    Flamingo Capri (nicht zu verwechseln mit dem bekannteren Flamingo) wird zum Imperial Palace.Slots-a-Fun wird eröffnet, das kleinste Casino auf dem Strip (und
    das einzige ohne Hotel).Vegas World wird eröffnet und läuft bis 1995 (um 1996
    durch das Stratosphere ersetzt zu werden). Das Bellagio wird an der
    Stelle des ehemaligen Dunes eröffnet. Wild Wild West, ein reines Spielautomatencasino
    in der Nähe des Strip, wird geschlossen und soll von seinem Eigentümer
    (Red Rock / Station) abgerissen werden, um Platz für ein größeres Gebäude zu schaffen. Das Fontainebleau soll 2023 auf
    dem Strip eröffnet werden, nachdem es 20 Jahre lang abwechselnd gebaut und pausiert wurde.

    Das Angebot der Download und der Flash Version bedeutet, dass Du die hochwertige Auswahl des Casino Las Vegas von über 80 Casino Spielen sofort spielen kannst, einschließlich der Arcade und Kartenspiele,
    progressiver Spiele, sowie regulärer und Video Slots.
    Sie bentigen mglicherweise eine Internetverbindung, um House of Fun zu spielen und auf die sozialen Funktionen zuzugreifen. Wenn Sie spätabends
    einen Blick in diesen Raum werfen, können Sie vielleicht Profis sehen, die um Millionen spielen. Also,
    Lieblingsspiel auswählen, sofort spielen – und richtig
    Spaß haben!

    References:
    https://online-spielhallen.de/evolve-casino-bonus-codes-ihr-umfassender-leitfaden/

  12. Discover the secrets of 999,999,999,999,999,999,999 with our full breakdown of its
    prime factors, divisors, and mathematical properties… This visualization shows the relative proportions of
    its 7 prime factors (outer circle), plus the relationship between these and its 256 divisors.

    You could say that a number is made or ‘composed’ of its prime factors.
    Its factors, divisors, and base properties can show some interesting behavior.

    It has a total of two hundred fifty-six divisors.
    It is composed of seven distinct prime numbers multiplied together.

    Here we have made a list of the currency names you would need to write
    spellings in order to deposit money against your currency
    cheques, DD, loan payments or more. Prime factors of a number
    are the prime numbers that multiply together to form that number.
    Like all numbers, it has a distinctive mathematical structure.

    References:
    https://blackcoin.co/what-is-a-high-roller-best-high-roller-online-casinos/

  13. It was capable of autonomously performing tasks through web browser interactions, including filling forms, placing online orders, scheduling appointments, and other browser-based tasks.
    These include, among many others, writing and debugging computer programs, composing music, scripts, fairy tales, and essays, answering questions (sometimes at a level
    exceeding that of an average human test-taker), and generating business concepts.
    It is designed to generate human-like text and can carry out a wide variety
    of tasks. ChatGPT’s training data includes software manual pages, information about internet phenomena such as bulletin board
    systems, multiple programming languages, and the text of Wikipedia.

    Air Evac Lifeteam is the leading provider of
    emergent air medical transportation services, operating more than 150 helicopter air ambulance bases across 15 states.

    In October 2025, OpenAI reported that approximately 0.15% of ChatGPT’s active users
    in a given week have conversations including explicit indicators of potential
    suicidal planning or intent, translating to more than a million people weekly.
    Many individuals use ChatGPT and comparable large language models mental health and emotional
    support. The ChatGPT-generated avatar told the people,
    “Dear friends, it is an honor for me to stand here and preach to you as the first artificial intelligence at this year’s convention of Protestants in Germany”.
    As of July 2025, Science expects authors to release in full how
    AI-generated content is used and made in their work.

    The chatbot can assist patients seeking clarification about their health.
    This has led to concern over the rise of what has come to be called “synthetic media” and
    “AI slop” which are generated by AI and rapidly spread over social
    media and the internet. Between March and April 2023, Il Foglio published one
    ChatGPT-generated article a day on its website, hosting
    a special contest for its readers in the process.
    In an industry survey, cybersecurity professionals argued that it was attributable to cybercriminals’ increased use of
    generative artificial intelligence (including ChatGPT).
    Chris Granatino, a librarian at Seattle University,
    noted that while ChatGPT can generate content that seemingly includes
    legitimate citations, in most cases those citations are not real or largely incorrect.

    References:
    https://blackcoin.co/casino-wharf-fx-a-comprehensive-overview/

  14. Relax in one of the 152 stylishly appointed hotel
    or resort rooms, swim in our spectacular infinity-edged pool or lagoon pool
    with a swim-up bar, enjoy the cuisine of our five distinctive dining experiences, indulge in spa treatments, and relax on our
    beautiful private beach. IKOU creates a fusion of wild-harvested indigenous ingredients combined with global spa traditions for a
    sensory experience that not only deeply relaxes, but also connects
    you with the true heart of this ancient land. Our private dining room provides
    an ideal setting for special occasions, corporate events,
    or intimate get-togethers.
    Mindil Beach Casino Resort is an ultimate travel destination for
    discerning guests seeking a truly five-star beachfront experience in Australia’s extraordinary Top End.
    Visit the Lucky North® Club desk located
    at the casino main entrance to join for free today.
    Whether it’s a casual catch-up with friends or something a little more special, experience some of the best dining options
    in Darwin. As well as a range of unique function and
    conference spaces, we also offer stylish hotel rooms and suites, restaurants, bars, and casino.
    You must be 18 years or over to enter the casino. Pop the sunnies on and pamper
    yourself with a day blissfully lounging on a sunbed, swimming
    in the glistening infinity pool, and grazing
    on beachy bites.

    References:
    https://blackcoin.co/lakeside-inn-and-casino-an-in-depth-look/

  15. Enjoy an exclusive 10% discount on all specials when you dine as a member
    Whatever you’ve got in mind, we can cater for a wide range of occasions, including birthdays and
    celebrations, weddings, business conference and meetings, major community events, festivals,
    outdoor concerts, and gala dinners. POKER TOURNAMENTEvery
    second Saturday from 4pmMore details here Mindil Beach Casino Resort boasts an exclusive
    Table Games offering.
    Each room also includes a private patio, offering spectacular garden or ocean views.

    Located on the ground level of the hotel, these spacious rooms are fully equipped with a Japanese-inspired spa bath and a separate
    spacious corner shower. Superior Spa Rooms offer guests
    the ultimate relaxation experience. All rooms feature a private balcony, stylish
    ensuite bathroom, complimentary WiFi and a state-of-the-art flat screen television. The Garden Grand Suite offers guests an experience to remember.
    Use your points for Xtra Credits, dining, hotel stays and more.

    References:
    https://blackcoin.co/m99-casino-a-comprehensive-review/

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>