FacesMessage component is used to show confirmation, warning or informational message in Oracle ADF .In this tutorial, you will see that how to use
FacesMessage component to show Multiline Message.
Sometimes we need to show multilines message then how we implement this ?
this is same as FacesMessage implementation, you should know that af:messages support HTML formatting, so we use HTML formatting to show multiline messages
see more about FacesMessage -
http://www.awasthiashish.com/2012/10/show-facesmessage-in-oracle-adf.html
about inline message
http://www.awasthiashish.com/2012/10/show-inline-message-in-oracle-adf.html
Managed bean code to show multiline message in ADF using FacesMessage-
To use for Error and Warning just change FacesMessage.SEVERITY_INFO to SEVERITY_ERROR or SEVERITY_WARN.
It will look like this
You can change your Message accordingly
you can also use some html styles (CSS) to change color of text that appears in message body , see the changed code
now see the FacesMessage look like this-
Happy Learning :-) Download Sample App
this is same as FacesMessage implementation, you should know that af:messages support HTML formatting, so we use HTML formatting to show multiline messages
see more about FacesMessage -
http://www.awasthiashish.com/2012/10/show-facesmessage-in-oracle-adf.html
about inline message
http://www.awasthiashish.com/2012/10/show-inline-message-in-oracle-adf.html
Managed bean code to show multiline message in ADF using FacesMessage-
package multilineMessages.view.bean; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.faces.event.ActionEvent; public class MultilineMessageBean { public MultilineMessageBean() { } public void showMessage(ActionEvent actionEvent) { StringBuilder message = new StringBuilder("<html><body>"); message.append("<p><b>Hi This is Frist Line--Oracle ADF Message</b></p>"); message.append("<p><i>Hi This is Second Line--Oracle ADF Message</i></p>"); message.append("<p><b>Hi This is Third Line--Oracle ADF Message</b></p>"); message.append("</body></html>"); FacesMessage fm = new FacesMessage(message.toString()); fm.setSeverity(FacesMessage.SEVERITY_INFO); FacesContext fctx = FacesContext.getCurrentInstance(); fctx.addMessage(null, fm); } }
To use for Error and Warning just change FacesMessage.SEVERITY_INFO to SEVERITY_ERROR or SEVERITY_WARN.
It will look like this
You can change your Message accordingly
you can also use some html styles (CSS) to change color of text that appears in message body , see the changed code
public void showMessage(ActionEvent actionEvent) { StringBuilder message = new StringBuilder("<html><body>"); message.append("<p style='color:navy'><b>Hi This is Frist Line--Oracle ADF Message</b></p>"); message.append("<p style='color:green'><i>Hi This is Second Line--Oracle ADF Message</i></p>"); message.append("<p style='color:magenta'><b>Hi This is Third Line--Oracle ADF Message</b></p>"); message.append("<p style='color:red'><b><i>This is Fourth line--Oracle ADF Message</i></b></p>"); message.append("</body></html>"); FacesMessage fm = new FacesMessage(message.toString()); fm.setSeverity(FacesMessage.SEVERITY_INFO); FacesContext fctx = FacesContext.getCurrentInstance(); fctx.addMessage(null, fm); }
now see the FacesMessage look like this-
Happy Learning :-) Download Sample App
Very nice info!
ReplyDelete