开发者

JSF2 Messages tag for user interaction

I use the tag h:messages for displaying form validation messages (in a red error sty开发者_C百科le). I was wondering if you can use that tag to display other messages as well. For example a success message (obviously in another style) or an info message. So that I can integrate such a messages tag in any page and use it to provide information to the user.

Thank you for suggestions


Thank you for your answers.

But how does h:messages tag knows what styleClass is used for what severity ?

EDIT: Got it: infoStyle="color: green;" errorStyle="color: red;"


You can do that very easily. Just use the infoStyle attribute and you can add a message like this:

class MyBean {
    ...
    public void method() {
    //do something
    String summary = "Method executed succesfully!";
    getFacesContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, summary, null));
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜