Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8345759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:47:11+00:00 2026-06-09T06:47:11+00:00

How do you display XML content with line feeds (pretty print) in a PrimeFaces

  • 0

How do you display XML content with line feeds (pretty print) in a PrimeFaces dataTable column?

My XML content is already in pretty print format and I can see it with line feeds when doing a System.out.println from a FacesConverter that converts the bytes to a String before it is rendered on the table column.

Here is the code for the FacesConverter:

@FacesConverter(value="xmlStream")
public class ByteConverter implements Converter {

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        byte[] buffer = null;
        try{
            buffer = value.getBytes("UTF-8");
        }catch(UnsupportedEncodingException e){
            buffer = value.getBytes();
        }
        return buffer;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        String text = null;
        if (value instanceof byte[]){
            try{
                text = new String((byte[])value, "UTF-8");
            }catch(UnsupportedEncodingException e){
                text = new String((byte[])value);
            }
        }
        System.out.println("text=<" + text + ">");
        return text;
    }

}

And here is what I see in the console when doing a System.out.println above:

<linkUp>
  <ifName>eth1</ifName>
  <linkProperty>
    <name>1</name>
    <flags>42</flags>
    <extensions>
      <name>foo</name>
      <value>bar2</value>
    </extensions>
  </linkProperty>
  <linkProperty>
    <name>2</name>
    <flags>4668</flags>
    <extensions>
      <name>foo</name>
      <value>bar2</value>
    </extensions>
  </linkProperty>
</linkUp>   

But when the data displays on the PF dataTable column, it appears as a single line string without line feeds – Is there a way to display it as it displays on the console? How do others display XML content in a PF table?

Hmmm, It looks like this does the trick:

.whiteSpaceClass{
    white-space: pre-wrap;
}

But now I am having to deal with rows that span half the page because the XML is so large. I guess the old saying ‘Beware of what you ask for’ applies here…:)

Still, it would be nice to display just the first few lines and be able to expand / collapse the rest based on single click event, or even display it in a box when the cell is double clicked – problem is, I have no idea how to do that or if PF supports that…:)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:47:12+00:00Added an answer on June 9, 2026 at 6:47 am

    You could use expandable rows to show your entire XML.
    See a example of use of p:rowExpansion in showcase.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive been trying to display formatted content blocks from a xml file with no
I have an XML file from which I am parsing some content to display
I can directly read the XML Feed using jQuery, but when I display the
I want to display the content of an XML file in a web page
I want to display a regular XML or any other file in text format
I am loading an XML file then I will display the contents of it
Problem occured when i tried to display xml data that has been taken by
I'm using a form to display XML elements. Every time I click on a
How to display a XML document in a HTML page as a collapsible and
I'm trying to get an html page to display an XML file formatted with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.