如何更改p上的文字颜色:根据严重程度咆哮? [英] How to change text color on p:growl according to severity?

查看:156
本文介绍了如何更改p上的文字颜色:根据严重程度咆哮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要根据严重性,任何想法,在< p:growl> 上更改文本颜色。

I need to change the text color on <p:growl> according to severity, any idea?

我在这个方法中添加一个程序化的咆哮:

I'm adding a programmatic growl in this method:

public void addMessageGrowl(Severity typeMessage, String detailMessage) {
     FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(typeMessage, "", detailMessage));
}

调用此方法后:

addMessageGrowl(FacesMessage.SEVERITY_FATAL, "Ocurrió un error al ejecutar la operacion");

然而,我想自定义咆哮上的文字颜色。

I however, want to customize the text color on the growl.

推荐答案

如果您只想更改文本颜色,可以使用CSS sibbling选择器本机进行此操作:

If you just want to change the text color, you can do this natively with the CSS sibbling selector:

.ui-growl-image-info ~ .ui-growl-message {
    color:#0f0;
}
.ui-growl-image-error ~ .ui-growl-message {
    color:#f00;
}
.ui-growl-image-warn~ .ui-growl-message {
    color:#00f;
}
.ui-growl-image-fatal~ .ui-growl-message {
    color:#000;
}

如果要更改背景,您需要根据链接发表于@ÖmerFarukKurt:

If you want to change the background to, you need something according to the link posted by @ÖmerFarukKurt:

PrimeFaces咆哮动态更改颜色

这篇关于如何更改p上的文字颜色:根据严重程度咆哮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆