How To Insert Space in JSF Page [ nbsp was referenced but not declared Error ]

How-To-Insert-Non-Breaking-Space-in-JSF

Hi, Welcome to the practice house. As you all know in this house we share a lot of example programs and a lot of solutions for various kinds of problems that you face when you are trying to do some programming.

So, In this post, I am going to share with you How to Insert Space in JSF Pages. Maybe you are new in JSF or maybe you are used to with HTML. In HTML, we use   to have a non-breaking space.

But if you use this   inside the JSF Page, you will have
Error Parsing /page.xhtml: Error Traced[line: XX] The entity “nbsp” was referenced, but not declared

The Reason Why It Shows The Parsing Error

JSF ( Java Server Faces ), This Facelets is an XML based view technology. So XML has only 5 predefined entities.   not included. So it can’t parse the   as space. it will only work in plain HTML or in JSP.

How To Insert Non-Breaking Space in JSF [ Solution ]

So there is a lot of ways to do it. One by one I am sharing here. Just use whichever you want.

  1. Declare an Entity
  2. Use Hexadecimal
  3. You can change the Doctype Declaration with this
  4. You can use JSF outputText with Hexadecimal Value 160 or 141 or xA0


  5. If you are using RichFaces library use the tag rich:spacer which will add an “invisible” image with a given length and height.
  6. If you are using primeFaces

     

So Here you go with all kinds of solution that I came across when I was facing this problem. I hope it solves your problem and it will give you more ideas and concepts to solve this.

Thanks for visiting us. Let us know in the comment section. And still, you are not able to solve it. please let me know I will try my best to solve your problem. I love to solve problems.

For More Information and Resources:

StackOverflow Link 1

StackOverflow Link 2

Leave a Reply

avatar
  Subscribe  
Notify of