0

I've created a DefaultTreeNode with primefaces.It works alright but I'd like to have 2 lines on each node instead of one.Is it possible to do that. Here's what I've tried so far :

TreeNode node0 = new DefaultTreeNode("Node 0" +"\n" +" 2nd line", root);

and

TreeNode node0 = new DefaultTreeNode("Node 0" +"\r\n" +" 2nd line", root);

but none of them work.

Any idea ?

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
Jean
  • 601
  • 1
  • 10
  • 26
  • Did you check if the default CSS style rules for tree nodes wrap new lines? – Jasper de Vries May 04 '18 at 13:07
  • How would you do this in plain html? Within a div.... – Kukeltje May 04 '18 at 13:20
  • @Kukeltje do you mean using `
    `? Wouldn't that be escaped when the node is rendered?
    – Jasper de Vries May 04 '18 at 14:37
  • @JasperdeVries: No, I mean having a `
    Bla\nBla
    ` in plain html and then have that display an actual new line. Lots of questions on that in StackOverflow...
    – Kukeltje May 04 '18 at 14:41
  • @Kukeltje OK. I was also referring to that in my comment. I now spent more time commenting than it would take to find the duplicate... So here it is: – Jasper de Vries May 04 '18 at 14:45
  • Possible duplicate of [Line break in html with \`\n\`](https://stackoverflow.com/questions/39325414/line-break-in-html-with-n) – Jasper de Vries May 04 '18 at 14:45
  • hahaha... I missed your initial comment, Think it crossed mine... Hoped the OP would look for it. Too often they post something and vanish for more than a couple of days... Very frustrating – Kukeltje May 04 '18 at 14:51

1 Answers1

0

With h:panelGrid you can define the lines that you consider inside. You can also use it for columns.

<p:treeNode> 
    <h:panelGrid  columns="1"   cellpadding="1" columnClasses="label,value" >
        <p:column style="width:10%"> 
            <img src="#{node.t01IdT03.t03Icono}"  height="20" width="20"/>
        </p:column>
        <p:column style="width:10%"> 
            <img src="#{node.t01IdT02.t02Icono}"  height="20" width="20"/>
        </p:column>
        <p:column>
            <h:outputText value="#{node.t01NombreSitio}" />
        </p:column>
    </h:panelGrid>
</p:treeNode> 
Mickael Maison
  • 25,067
  • 7
  • 71
  • 68