<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: How to set icons in PrimeFaces tree nodes</title><link>https://answers.axonivy.com/questions/78/how-to-set-icons-in-primefaces-tree-nodes</link><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I would like to set icons in PrimeFaces tree nodes. My icons are configured in the project CMS.&lt;/p&gt;
&lt;p&gt;Unfortunately, the Resource Demo doesn't help me.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;p:tree id="treeSingle" value="#{treeBean.root}" var="node" selectionMode="single"
        selection="#{treeBean.selectedNode}"&amp;gt;
  &amp;lt;p:treeNode icon=""&amp;gt;
    &amp;lt;h:outputText value="#{node.name}" /&amp;gt;
  &amp;lt;/p:treeNode&amp;gt;
&amp;lt;/p:tree&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In &amp;lt;p:treenode&amp;gt; I need to set the icon attribute with a syntax that will retrieve icons from the CMS.&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/78/how-to-set-icons-in-primefaces-tree-nodes" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 18 Nov 2013 16:33:20 -0500</lastBuildDate><item><title>Comment by A1234 on Nikel Weis's answer</title><link>https://answers.axonivy.com/questions/78/how-to-set-icons-in-primefaces-tree-nodes#84</link><description>&lt;p&gt;Good point! Fixed it.&lt;/p&gt;
&lt;p&gt;I was inspired by the MethodCallbackDialog in the HtmlDialogDemos project.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">A1234</dc:creator><pubDate>Mon, 18 Nov 2013 16:33:20 -0500</pubDate><guid>https://answers.axonivy.com/questions/78/how-to-set-icons-in-primefaces-tree-nodes#84</guid></item><item><title>Comment by Nikel Weis on Nikel Weis's answer</title><link>https://answers.axonivy.com/questions/78/how-to-set-icons-in-primefaces-tree-nodes#83</link><description>&lt;p&gt;Better practice would be to place it within the &amp;lt;head&amp;gt;-Tag. But that should be done quickly. Glad to hear, that it helped.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nikel Weis</dc:creator><pubDate>Mon, 18 Nov 2013 16:22:20 -0500</pubDate><guid>https://answers.axonivy.com/questions/78/how-to-set-icons-in-primefaces-tree-nodes#83</guid></item><item><title>Comment by A1234 on Nikel Weis's answer</title><link>https://answers.axonivy.com/questions/78/how-to-set-icons-in-primefaces-tree-nodes#82</link><description>&lt;p&gt;Thanks Nikel,&lt;/p&gt;
&lt;p&gt;You saved my day!
To be precise, I created a CSS file "style.css" in "&amp;lt;project&amp;gt;/webContent", with the CSS-class content you mentioned.&lt;/p&gt;
&lt;p&gt;Then I added &amp;lt;h:outputstylesheet name="style.css"/&amp;gt; right after the &amp;lt;h:body&amp;gt; tag.&lt;/p&gt;
&lt;p&gt;And finally, I referenced the icon resource in my &amp;lt;p:treenode&amp;gt; tag.
That works.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">A1234</dc:creator><pubDate>Mon, 18 Nov 2013 10:01:43 -0500</pubDate><guid>https://answers.axonivy.com/questions/78/how-to-set-icons-in-primefaces-tree-nodes#82</guid></item><item><title>Answer by Nikel Weis</title><link>https://answers.axonivy.com/questions/78/how-to-set-icons-in-primefaces-tree-nodes/81</link><description>&lt;p&gt;Basically the icon attribute points to a css-class. So if you want to use custom icons  you need to create a custom css-class. For example:&lt;/p&gt;
&lt;p&gt;CSS-Class:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;.customIcon {
   background: transparent url("#{resource['ivy-cms:Images/customIconImage']}") no-repeat top !important;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Your code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[...]&amp;lt;p:treeNode icon="customIcon"&amp;gt;[...]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The CSS-class will now reference a file that is within the CMS-Folder Images/ and point to an image with name customIconImage (doesn't matter what format). You can also set the width and height within the CSS-class to control the size of the icon via CSS, although this is not recommended because this takes up bandwith when the original sized icon is loaded  and afterwards resized.&lt;/p&gt;
&lt;p&gt;Hope this helps.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nikel Weis</dc:creator><pubDate>Mon, 18 Nov 2013 09:21:06 -0500</pubDate><guid>https://answers.axonivy.com/questions/78/how-to-set-icons-in-primefaces-tree-nodes/81</guid></item></channel></rss>