white-space:pre-wrap;But what to do when you use Richafaces (Ajax4jsf) and have set this CSS property correctly but nevertheless whitespaces keep collapsing?
According to RichFaces Developer Guide:
RichFaces uses a filter for a correction of code received on an Ajax request. In case of a "regular" JSF request a browser makes correction independently. In case of Ajax request in order to prevent layout destruction it's needed to use a filter, because a received code could differ from a code validated by a browser and a browser doesn't make any corrections.Thus Richfaces parser do correct our HTML code, but the parser does not know anything about our CSS and thus here is the cause of the issue.
In Richfaces there are 2 types of parsers:
- Tidy is the default parser. It is similar to usual browser parsing. It's the slowest one from Richfaces parsers. On my opinion it should be used only with complicated markup
- Neko is less stricted and so it works faster
<context-param> <param-name>org.ajax4jsf.xmlparser.ORDER</param-name> <param-value>NEKO</param-value> </context-param> <context-param> <param-name>org.ajax4jsf.xmlparser.NEKO</param-name> <param-value>.*\..*</param-value> </context-param>If necessary you can configure filters flexibly for different pages (example)