How do you display XML content with linear channels (pretty print) in the DataTable PrimeFaces column?
My XML content is already in a fairly printed format, and I see it with line feeds when I execute System.out.println from FacesConverter, which converts bytes to a string before it is displayed in a table column.
Here is the code for 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 on the console when executing 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 is displayed in the PF dataTable data column, it is displayed as a single row row without linear feeds. Is there a way to display it when it is displayed on the console? How do others display XML content in a PF table?
Hmmm, this seems like a trick:
.whiteSpaceClass{
white-space: pre-wrap;
}
, , XML . , " , " ...:)
, / , - , , , PF ...:)