1

I have a string which looks like an absolute path : Dir1\Important\Info 123\test. I have that string in a h:outputText tag.

I want to word-wrap that string just before ot just after the \ character. The default wrapping in css is for whitespaces. I can't use that because I have whitespaces in the some names. I want the string to break only at the \ character.

How can I achive such word-wrapping? Any help is welcomed :)

PS: I can use <wbr> to give it a hint, but the problem with the whitespaces stays.

PSS: The tag looks like this:

<h:outputText id="fullPath"           value="#{configItemDtoSearch.fullPath}" 
                                      style="color:#03A9F4; font-style: italic; white-space: nowrap; width: 200;"/>
user3719857
  • 1,083
  • 4
  • 16
  • 45

2 Answers2

1

If you set the CSS property to no-wrap and then add <wbr /> tags after each \ character then you should get the desired wrapping.

Here is an example - https://jsfiddle.net/f1t29gb4/. This works in Chrome but I've not tested it elsewhere.

BrettJephson
  • 416
  • 5
  • 13
1

You can use &nbsp; instead of the white space characters. &nbsp; is a non breaking space character. So the string should look like:

Dir1\<wbr />Important\<wbr />Info&nbsp;123\<wbr />test
Anton
  • 2,458
  • 2
  • 18
  • 30
  • I replaced the normal whitespaces with the non-breaking one and added the . When I use the `nowrap` property. The string doesn't break anywhere. When I omit the `white-space` property the string still breaks at the whitespaces (the replaced with non-breaking ones). Any ideas ? – user3719857 Jan 14 '16 at 09:13
  • 1
    Here is a [working fiddle](https://jsfiddle.net/h2j4k3vk/2/) - please notice the white-space is set to "normal" (same as if it was omitted at all). Have you checked the HTML markup generated by the h:outputText tag? Is the final string in the HTML same as the one I posted above? – Anton Jan 14 '16 at 09:43