From 1f67cca3ebfd3f191cc5266a5d95dbbda6653245 Mon Sep 17 00:00:00 2001
From: David Huynh
Date: Wed, 16 Jun 2010 00:09:12 +0000
Subject: [PATCH] Added Java code to sample extension.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@979 7d457c2a-affb-35e4-300a-418c747d4874
---
extensions/sample-extension/.classpath | 2 +-
.../sample-extension/MOD-INF/controller.js | 5 ++++-
extensions/sample-extension/sample-extension/index.vt | 2 +-
.../com/metaweb/gridworks/sampleExtension/SampleUtil.java | 8 ++++++++
4 files changed, 14 insertions(+), 3 deletions(-)
create mode 100644 extensions/sample-extension/src/com/metaweb/gridworks/sampleExtension/SampleUtil.java
diff --git a/extensions/sample-extension/.classpath b/extensions/sample-extension/.classpath
index 7938e78d6..82d122a6f 100644
--- a/extensions/sample-extension/.classpath
+++ b/extensions/sample-extension/.classpath
@@ -2,5 +2,5 @@
-
+
diff --git a/extensions/sample-extension/sample-extension/MOD-INF/controller.js b/extensions/sample-extension/sample-extension/MOD-INF/controller.js
index 0ab4692f6..c52655b0b 100644
--- a/extensions/sample-extension/sample-extension/MOD-INF/controller.js
+++ b/extensions/sample-extension/sample-extension/MOD-INF/controller.js
@@ -36,7 +36,10 @@ function process(path, request, response) {
if (path == "/" || path == "") {
var context = {};
- context.someVar = "foo"; // here's how to pass things into the .vt templates
+ // here's how to pass things into the .vt templates
+ context.someList = ["Superior","Michigan","Huron","Erie","Ontario"];
+ context.someString = "foo";
+ context.someInt = Packages.com.metaweb.gridworks.sampleExtension.SampleUtil.stringArrayLength(context.someList);
send(request, response, "index.vt", context);
}
diff --git a/extensions/sample-extension/sample-extension/index.vt b/extensions/sample-extension/sample-extension/index.vt
index 3791a3a23..e00016132 100644
--- a/extensions/sample-extension/sample-extension/index.vt
+++ b/extensions/sample-extension/sample-extension/index.vt
@@ -13,7 +13,7 @@
and styles into the /project page.
- Here is someVar: $someVar.
+ Here is someString: $someString, and someInt: $someInt
Here is a sample list using a veloci-macro:
diff --git a/extensions/sample-extension/src/com/metaweb/gridworks/sampleExtension/SampleUtil.java b/extensions/sample-extension/src/com/metaweb/gridworks/sampleExtension/SampleUtil.java
new file mode 100644
index 000000000..fdf415488
--- /dev/null
+++ b/extensions/sample-extension/src/com/metaweb/gridworks/sampleExtension/SampleUtil.java
@@ -0,0 +1,8 @@
+package com.metaweb.gridworks.sampleExtension;
+
+
+public class SampleUtil {
+ static public int stringArrayLength(String[] a) {
+ return a.length;
+ }
+}