Why does allow blank spaces?

That’s normal and natural behaviour and not JSF specific. A blank space may be perfectly valid input. The required=”true” only kicks in on empty inputs, not in filled inputs. In JSF you can however just create a Converter for String class to automatically trim the whitespace. @FacesConverter(forClass=String.class) public class StringTrimmer implements Converter { @Override public … Read more

Mysterious whitespace in between Bootstrap2 Navbar and row underneath

You may want to override the margin-bottom: 20px from navbar : .navbar { margin-bottom: 0; } Something like that : http://jsfiddle.net/q4M2G/ (the !important is here just to override the style of the CDN version of bootstrap I’m using in the jsfiddle but you should not need to use it if your style correctly overrides bootstrap … Read more

How to preserve whitespace indentation of text enclosed in HTML tags excluding the current indentation level of the tag in the document?

Indenting With Comments Since browsers ignore comments, you can use them to indent your pre tag contents. Solution <html> <body> <main> Here is my code with hack: <pre> <!– –>def some_function <!– –> return ‘Hello, World!’ <!– –>end </pre> Here is my code without hack: <pre> def some_function return ‘Hello, World!’ end </pre> </main> <body> … Read more

Replace tabs and spaces with a single space as well as carriage returns and newlines with a single newline

First, I’d like to point out that new lines can be either \r, \n, or \r\n depending on the operating system. My solution: echo preg_replace(‘/[ \t]+/’, ‘ ‘, preg_replace(‘/[\r\n]+/’, “\n”, $string)); Which could be separated into 2 lines if necessary: $string = preg_replace(‘/[\r\n]+/’, “\n”, $string); echo preg_replace(‘/[ \t]+/’, ‘ ‘, $string); Update: An even better … Read more