Skip to content

Instantly share code, notes, and snippets.

<h:form>
<p:menu>
<p:menuitem value="Computers" url="#"/>
<p:menuitem value="Clothes" url="#"/>
<p:menuitem value="Gaming" url="#"/>
<p:menuitem value="Books" url="#"/>
<p:menuitem value="Jewellery and Watches" url="#"/>
</p:menu>
</h:form>
@kevindoran
kevindoran / Blogger.java
Created February 15, 2012 07:27
Simple Programmatic Menu Model with Primefaces
@ManagedBean
@SessionScoped
public class BloggerBean {
private MenuModel simpleMenuModel = new DefaultMenuModel();
public BloggerBean() {
MenuItem menuItem = new MenuItem();
menuItem.setValue("Computers");
menuItem.setUrl("#");
@kevindoran
kevindoran / CategoryMenuModel.java
Created February 15, 2012 08:06
Dynamic Category Menu Model
public class CategoryMenuModel implements MenuModel, ActionListener, Serializable {
private static final long serialVersionUID = -2866930830066526910L;
protected Category category;
protected List<UIComponent> contents = new ArrayList<>();
protected static UIViewRoot uiViewRoot = new UIViewRoot();
public Category getCategory() {
return category;
}
@kevindoran
kevindoran / BloggerBean2.java
Created February 15, 2012 08:31
BloggerBean2
@ManagedBean
@SessionScoped
public class BloggerBean {
private CategoryMenuModel menuModel = new CategoryMenuModel();
public BloggerBean() {
menuModel.setCategory(new Category("Computers"));
}
@kevindoran
kevindoran / index.xhtml
Created February 15, 2012 08:33
indexFile
<h:form>
<p:menu model="#{bloggerBean.simpleMenuModel}"/>
</h:form>
@kevindoran
kevindoran / googleCharts.xhtml
Last active September 30, 2015 20:27
Google Charts XHTML page
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:gc="http://nz.co.kevindoran/googlecharts">
<h:head>
<title>Google Charts with JSF Test</title>
</h:head>
<h:body>
<h2>Google Charts with JSF Test</h2>
@kevindoran
kevindoran / ChartBackBean.java
Last active September 30, 2015 20:27
Google Charts BackBean
@ManagedBean
public class ChartBackBean {
private GoogleChartModel chartModel = new DefaultGoogleChartModel("AnnotatedTimeLine");
public ChartBackBean() {
chartModel.addColumn(new Column(Column.JavaScriptType.date, "Date"));
chartModel.addColumn(new Column(Column.JavaScriptType.number, "Price"));
for(int i=20; i>0; i--) {
@kevindoran
kevindoran / Category.java
Created May 29, 2012 22:24
Dynamic Category Menu Model
public interface Category {
String getName();
Collection<Category> getChildCategories();
}
@kevindoran
kevindoran / nzPopulationMakeUp.xhtml
Last active December 9, 2015 20:38
A snippet from a JSF XHTML page used to create a Highchart chart using JSF.
<!-- Note: I tried to include these scripts within the composite component XHTML pages
(where they belong), but I got JSF errors (apparently, a Bug in latest Mojarra JSF).-->
<h:outputScript library="javascript/highcharts/js/" name="highcharts.js" target="head" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
</h:head>
<h:body>
<h1>New Zealand National Ethnic Population Projections</h1>
<div id="subtitle">
Projections for the New Zealand Population makeup for the year 2026 using
data from 2006. For more information, see
@kevindoran
kevindoran / NZEthnicPopulation2006.java
Created December 18, 2012 04:48
Backing bean for JSF-Highchart chart.
import javax.faces.bean.ManagedBean;
import nz.co.tradeintel.highcharts.ColumnChartSeries;
@ManagedBean
public class NZEthnicPopulation2006 {
private ColumnChartSeries nzEuropeanSeries = new ColumnChartSeries();
private ColumnChartSeries maoriSeries = new ColumnChartSeries();
private ColumnChartSeries pacificSeries = new ColumnChartSeries();
private ColumnChartSeries asianSeries = new ColumnChartSeries();