Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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}',
<dependencies>
<dependency>
<groupId>nz.co.kevindoran</groupId>
<artifactId>google-charts-jsf</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
@kevindoran
kevindoran / menuTable.xhtml
Last active December 12, 2015 01:08
XHTML file for JSF Menu Table
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:mt="http://nz.co.kevindoran/jsf-menu">
<h:head>
<title>Menu Table Test</title>
</h:head>
<h:body>
<h:form>
<h2>JSF Menu Table Test</h2>
Current category: #{randomMenu.currentCategory}
@kevindoran
kevindoran / randomMenu.java
Last active December 12, 2015 01:08
Random menu back bean for JSF menu table
import nz.co.kevindoran.jsfmenutable.MenuTable;
import nz.co.kevindoran.jsfmenutable.Subscriber;
@ManagedBean
@ViewScoped
public class RandomMenu {
private MenuTable<Category> menuTable;
private static final int columnCount = 4;
private Category currentCategory = new Category();
@kevindoran
kevindoran / MenuTable.xhtml
Created February 1, 2013 01:03
Menu Table JSF Composite Component
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<cc:interface>
<cc:attribute name="model" type="nz.co.kevindoran.jsfmenutable.MenuTable"/>
<cc:attribute name="updateID" />
</cc:interface>
@kevindoran
kevindoran / MenuTable.java
Created February 1, 2013 01:06
MenuTable back bean
public class MenuTable<T> {
public List<Row<T>> rows;
private List<Subscriber<T>> subscribers = new ArrayList<>();
private int noOfColumns;
public MenuTable(int noOfColumns) {
this.noOfColumns = noOfColumns;
}
public void setContents(Collection<T> objects) {
@kevindoran
kevindoran / primefacesMenu.xhtml
Created February 1, 2013 02:42
Primefaces dynamic menu test
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Primefaces Dynamic Menu Test</title>
</h:head>
<h:body>
<h3>Primefaces Dynamic Menu Test</h3>
<h:form>
<p:menu model="#{randomMenu2.menuModel}" />
@kevindoran
kevindoran / RandomMenu2.java
Created February 1, 2013 02:57
Random menu back bean- primefaces version.
@ManagedBean
@ViewScoped
public class RandomMenu2 {
private MenuModel<Category> menuModel;
private Category currentCategory = new Category();
public RandomMenu2() {
menuModel = new MenuModel<>();
menuModel.setContents(currentCategory.getChildCategories());