Skip to content

Instantly share code, notes, and snippets.

@kevindoran
kevindoran / ColumnSeries.xhtml
Created December 18, 2012 04:58
JSF composite component to render the data (and some options) for a Highchart chart.
<cc:interface>
<cc:attribute name="name" default=""/>
<cc:attribute name="series" type="nz.co.tradeintel.highcharts.ColumnChartSeries"/>
</cc:interface>
<cc:implementation>
if(typeof options.xAxis.categories === "undefined") {
options.xAxis.categories =
[<ui:repeat value="#{cc.attrs.series.columns}" var="column">
'#{column.name}',
@kevindoran
kevindoran / ColumnChart.xhtml
Created December 18, 2012 04:55
JSF composite component to render a Highchart chart.
<cc:interface>
<cc:attribute name="title" default=""/>
<cc:attribute name="subTitle" default =""/>
<cc:attribute name="yLabel" default =""/>
<cc:attribute name="xLabel" default=""/>
<cc:attribute name="xMinTickInterval" default="0" />
</cc:interface>
<cc:implementation>
<div id="#{cc.id}_chartDiv"/>
@kevindoran
kevindoran / ColumnChartSeries.java
Created December 18, 2012 04:50
Back-end chart-model for JSF-Highchart charts.
public class ColumnChartSeries {
private ArrayList<ColumnData> columnData = new ArrayList<>();
public ColumnChartSeries() {
}
public void addColumn(String columnName, Number value) {
ColumnData d = new ColumnData(columnName, value);
columnData.add(d);
}
@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();
@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 / Category.java
Created May 29, 2012 22:24
Dynamic Category Menu Model
public interface Category {
String getName();
Collection<Category> getChildCategories();
}
@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 / 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 / index.xhtml
Created February 15, 2012 08:33
indexFile
<h:form>
<p:menu model="#{bloggerBean.simpleMenuModel}"/>
</h:form>
@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"));
}