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.
- Declare an Entity
123<!DOCTYPE html [<!ENTITY nbsp " ">]>
- Use Hexadecimal
1  or   or 
- You can change the Doctype Declaration with this
12<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- You can use JSF
outputTextwith Hexadecimal Value
1<h:outputText value=" " />
1<h:outputText value=" " />
1<h:outputText value="& nbsp;" escape="false"/>
- If you are using RichFaces library use the tag
rich:spacerwhich will add an “invisible” image with a given length and height.
1<rich:spacer height="1" width="2" />
- If you are using primeFaces
1<p:spacer width="10" />
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:
I love to explore new technologies. If you like my tutorials please share your thoughts about my work.
Check out my YouTube Channel For Video Tutorials.
To Hire Me Please Contact Me Through Social Media or https:www.amialif.com
If you want to help others by doing donation please Donate To These Charities.
You also can connect with me via social media. Thanks