How to show multi-lines af:message

Environment (JDeveloper 11.1.2.0.0, ADF Faces)

In the last post, I have explained how to show af:message programatically. In some cases the user may need to show a multi-lines message, in this post I will explain how to do this.

af:message allows us to include a formatted text in the message, this can be done by surrounding the message text with <html> tags. So to show a multi-lines message, we can use <p> tag  in our message text. The method below displays three lines message.

public String shwoMultiLinesMessage() {
        StringBuilder builder = new StringBuilder(“<html> <body>”);
        builder.append(“<p>First Line</p>”);
        builder.append(“<p>Second Line</p>”);
        builder.append(“<p>Third Line</p> “);
        builder.append(“</body> </html>”);
        FacesMessage fm = new FacesMessage(builder.toString());
        fm.setSeverity(FacesMessage.SEVERITY_INFO);
        FacesContext context = FacesContext.getCurrentInstance();
        context.addMessage(null, fm);
        return null;
    }

The result is af:message with three lines as shown in the image below:

mult-lines message

multi-lines message

Advertisements

2 Comments

Filed under ADF

2 responses to “How to show multi-lines af:message

  1. Jadon

    How to set height and width of af:messages window?
    It do not auto re-size unlike dialog box?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s