Skip to content
Groovy 24 – Multi Line Custom Validation Rule Message and Other Formation Of the Validation Error Message Using HTML

Everyone knows the classic line of code to generate a custom error message:

        throw new oracle.jbo.ValidationException("MESSAGE HERE")
        

We can make use of HTML to make this error message more exciting as shown below.

1 - Create Multi-Line Validation Messages

a) Lines are Close Together
Use the break line HTML tag <br>:

        throw new oracle.jbo.ValidationException("<html><body><p>MESSAGE 1 <br> MESSAGE 2 <br> MESSAGE 3 <br> MESSAGE 4</p></body></html>")
        

b) Lines have a space between them
Use multiple <p> tags:

        throw new oracle.jbo.ValidationException("<html><body><p>MESSAGE 1 </p><p> MESSAGE 2 </p><p> MESSAGE 3 </p><p> MESSAGE 4</p></body></html>")
        

2 - Create Bold Validation Messages
Use the <b> tag:

        throw new oracle.jbo.ValidationException("<html><body><b>This is Bold Message</b> And This is Not</body></html>")
        

3 - Add a link to your Error Message that can be clicked
Use <a href="address"> text </a> tags:

        def x = "https://www.w3schools.com"
throw new oracle.jbo.ValidationException("<html><body>Click The Following Link: <a href=${x}>Visit W3Schools</a></body></html>")

4 - Make Italic Message

Use the <i> tag:

        throw new oracle.jbo.ValidationException("<html><body>This is <i>ITALIC</i> Message</body></html>")