I want to include 'sample code' in a JSF page. Customers should be able to read this code and copy-paste this. Any idea how to do this?
It should look like this code-block below here on StackOverflow:
<p:splitButton value="Save" update="messages" icon="ui-icon-disk">
<p:menuitem value="Update" outcome="splitButton.xhtml" update="messages" icon="ui-icon-arrowrefresh-1-w" />
<p:menuitem value="Delete" outcome="splitButton.xhtml" icon="ui-icon-close" />
<p:separator />
<p:menuitem value="Homepage" url="http://www.primefaces.org" icon="ui-icon-extlink" />
</p:splitButton>
I don't find any good examples on this topic. Help is appreciated.
I have been using Google Code Prettify. It consists of CSS and JS files and also has tons of color themes. Try putting your code in a message bundle and include it with:
Messages
test.pretty=<p:splitButton value="Save" update="messages" icon="ui-icon-disk">\n ...
XHTML
<pre class="prettyprint linenums">
<h:outputText value="#{messages['test.pretty']}" escape="true"/>
</pre>
Output
You can find the project here, and color themes here.
If you'd rather go small footprint, then you could use <pre>
tag and own CSS.