h:outputText换行符,用于字符串中的长单词 [英] h:outputText line break for long words within strings

查看:349
本文介绍了h:outputText换行符,用于字符串中的长单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以告诉JSF(2.0)的h:outputText在字符串中的很长的单词中插入换行符(或更妙的是:诸如-"之类的自定义字符串)? 我的问题是,当字符串中有很长的单词且没有空格时,我的数据表(PrimeFaces)变得太宽.当我有一个长文本正常"字词,然后在下一行中打印下一个字词时,它会起作用.

虽然我可以使用转换器,但这仍然意味着我必须在字符串中查找长单词,然后在每次显示文本时都将其剪切.对于少量的数据,这将以某种方式起作用,但是当数据库变得更大时(并且将会),它需要大量的处理能力.

在插入数据库之前,我还可以扫描字符串中的长单词,这意味着我只需要处理一次字符串,而且如果我愿意的话,我也无法完全重建原始字符串需要它.

有人对此有任何意见吗?

先谢谢您,并致以最诚挚的问候, 罗伯特

解决方案

设置CSS 的相关元素的属性> .

<h:outputText styleClass="someClass" />

使用

.someClass {
    word-wrap: break-word;
}

Is there a way to tell h:outputText of JSF (2.0) to insert a line break (or even better: A custom string like "-") into very long words within strings? My problem is that my data-table (PrimeFaces) gets too wide when I have a very long word within a string with no spaces. It works when I have a long text "normal" words, then the next word is printed in the next line.

While I could use a converter, this would still mean that I have to look for long words within a string and then cut them every time I display the text. This would work somehow for a small amount of data, but needs a lot of processing power when the database is getting bigger (and it will).

I also could scan the string for long words before inserting into the database, which would mean that I only have to process the string once, but also that i'm not able to fully reconstruct the original string if I'd ever need it.

Does anyone have any input on this?

Thank you in advance and best regards, Robert

解决方案

Set CSS word-wrap property of the element in question to break-word.

<h:outputText styleClass="someClass" />

with

.someClass {
    word-wrap: break-word;
}

这篇关于h:outputText换行符,用于字符串中的长单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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