java FacesMessage Jsf 中的换行符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6039885/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 14:04:52  来源:igfitidea点击:

New Line character in FacesMessage Jsf

javajsfrichfaces

提问by Muneeswaran Balasubramanian

I wants to display the error message like, "The following headers not avail

我想显示错误消息,例如“以下标题无效

1.Name
2.Roll no

How can i show this using faces message in jsf?Please help me.

我如何在 jsf 中使用面消息来显示这个?请帮帮我。

采纳答案by maple_shaft

Without implementing a bizarre hack using javascript and css or without implementing your own JSF messages custom component this is not possible.

如果不使用 javascript 和 css 实现一个奇怪的 hack 或者不实现您自己的 JSF 消息自定义组件,这是不可能的。

You will need to create a new FacesMessage for each line.

您需要为每一行创建一个新的 FacesMessage。

回答by Andrew

Simply set escape="false"on the <p:messages>component in PrimeFaces 3.3+.

只需在 PrimeFaces 3.3+ 中escape="false"<p:messages>组件上进行设置

回答by Mahammad Aziz Ajmeri

you can do it using tag. You need to render this outputText on submit event and then display message in . You have to change escape attribute to false and user tag in you message where you need break. So in above case take one, 2.Roll" escape="false" render="your validation"/>

你可以使用标签来做到这一点。您需要在提交事件上呈现此 outputText,然后在 . 您必须在需要中断的消息中将转义属性更改为 false 和用户标记。所以在上面的例子中, 2.Roll" escape="false" render="your validation"/>

回答by vssk

Try this one:

试试这个:

new FacesMessage(FacesMessage.SEVERITY_ERROR,
                 "Title",
                 "<html>List:<ul><li> List item 1;</li><li> List item 2;</li><li> List item 3.</li></ul></html>")