Wednesday 31 December 2008

Apache Ant + Ivy on OSX

In order to get Apache Ivy working from the command-line on OS X, I did the following:



(Get the current versions of Ant and Ivy)


(or copy the folder to /usr/local and create a symlink to ant)

(For the sake of simplicity, I'm just copying the ivy jar into Ant's lib folder):


(Set the home for the current session - this should be added to bashrc in order for it to work permanently)


Test with:


(You should see something like)
Apache Ant version 1.7.1 compiled on June 27 2008

If so, you can go into one of the ivy example folders:



If this has worked, you should see:

run:
[java] standard message : hello ivy !
[java] capitalized by org.apache.commons.lang.WordUtils : Hello Ivy !

BUILD SUCCESSFUL

If you want to use ivy in Eclipse, all you should need to do is make sure the jar is in the buildpath.


I found this guide pretty useful for installing Ant in OS X:
http://www.asceticmonk.com/blog/?p=388

Tuesday 23 December 2008

Compiling AS3 classes on the command line

As an update to my previous posting - I've just discovered this:

If you've installed the free Adobe Flex SDK, you can use the command line to compile .as files, making it possible for you to use any editor you like to author your Actionscript files.

Obviously one of the reasons I was so interested in using IntelliJ is because you can compile and run your flash movies through the debugger (as you can with the FlexBuilder eclipse plugin). However, this may well be useful for someone.

First cd to wherever you installed your SDK - in this case, for Leopard:



It'll load a flex-config.xml file (in the frameworks folder), write out any errors / warnings and then tell you that it has created:

ClassName.swf (and output the size in bytes).

Also (may be worth noting):



This approach could (possibly?) be useful if you were building an application that would compile as3 classes as part of its execution, or if you were using ANT to compile an as3 app as part of a build process (there are a few blog postings on this too).

Quick disclaimer:

It should probably be said that it's currently unclear to me whether mxmlc.jar is part of the SDK or whether it's part of the eclipse plugin. If you were planning to use it as part of an application, you would need to check licencing requirements with Adobe.

Saturday 20 December 2008

Editing/Authoring Actionscript 3 Classes in IntelliJ IDEA

I wanted to see whether it was viable to use IntelliJ 8 as an IDE for creating complete Flash applications (for writing Actionscript). By default, the application allows you to create Flex applications and creates a "HelloWorld" app to get you started. But at first it was unclear how I could write AS3 classes and compile them without jumping over to flash or using FlexBuilder.

I spent some time today dealing with issues regarding certain flash Objects (namely the Stage) being "null" and after some reading, I discovered this was to do with timing - I read around online and after looking in many places, I pieced together this mxml file:



This replaced the HelloWorld.mxml that IntelliJ provided and it does two things:

1. Waits until "applicationComplete" (so the 'stage' exists).

2. Runs a function called init(), this instantiates Shell.as and places it on the stage (as a 'raw' child element). Once shell has been instantiated, init() is run and this can do whatever you like really - instantiate other classes, place objects on the stage, etc.

IntelliJ will use the Flex SDK's compiler to 'build' all of your project .as files; all you need to do is tell it where to find the Flex 3 SDK (in Leopard, it was installed by default in: /Applications/Adobe Flex Builder 3 Plug-in/sdks)

Once you've got some code written in the shell, you can use the IntelliJ debugger to run the app, inspect trace statements and so on. Although it's not quite as easy to "get up and go" with IntelliJ as it is with the FlexBuilder plugin (or application), it still makes authoring AS3 possible using IntelliJ.

Example Shell.as (will trace out the stage width and height):


Hope this is useful to someone who had wanted to know how to use IntelliJ as an Actionscript IDE and who was finding the same issues I had been running into.

Sunday 7 December 2008

STAX - Parse an XML Doc and print out all the attributes of that element

This might be useful for anyone looking for a simple example for Stax - this will run through a locally saved xml file and write out the element and all its attributes:

Saturday 6 December 2008

Getting the finder to display the $PWD

If you want to be able to see the path to the folder you're looking at:



Source: http://www.macosxtips.co.uk/index_files/terminal-commands-for-hidden-mac-os-x-settings.html

Sunday 30 November 2008

Open Finder at PWD

Tuesday 25 November 2008

Getting Lat and Long values from Google maps

This is listed in countless other places, but I didn't want to lose track of it:

Centre an item in google maps and put this in the address bar -



This will alert the lat and long values to the screen.

Original hint found here (with thanks!):
http://birdhouse.org/blog/2008/05/01/get-latlong-from-google-maps/

Sunday 16 November 2008

Java: Using Jersey and Grizzly to create a RESTful Framework for Web Applications

Here are some notes if you want to get started building a basic Jersey / Grizzly REST framework. The information here should be enough to get you started with the application launcher and a couple of resources which you can then test in a browser.

I got started by following the notes here as much as possible and then tried to boil the information down in order to give myself the most basic understanding of how these frameworks could be used in projects:

https://jersey.dev.java.net/use/getting-started.html

I created a new project in my favourite editor (IntelliJ IDEA) and then placed the following .jar files in my lib directory:

In the src folder, I created the following files (note: you'll need to edit the line containing "YOUR.NAMESPACE.HERE" and replace it with your namespace:

LaunchApp.java:


I placed the next two files in a folder called resources (src/YOUR/NAMESPACE/resources), so the config class could find and register them:

HelloWorldResource.java:


GreetPersonResource.java:


Once they're all in place and you have imported the jar folder into the project, you should be able to run LaunchApp and visit the following URIs:


And finally, I got myself up and running by looking at this page and downloading the project:

http://docs.sun.com/app/docs/doc/820-4867/ggqzb?a=view

I hope this helps someone get started quickly.

Friday 14 November 2008

PHP: parsing an include

If you're using php include a fair amount, you may well get to a point where you don't just want to 'drop' some text into your document but need to resolve variables etc.

There is a written function in the php manual that allows 'included' php to be parsed - hopefully this post will make the code snippet slightly more visible to someone and hence save them some time: (from http://www.php.net/include/)



If you use this block of code, you can pass in the name of a file to be included and the resultant page will return with any php processing fully parsed (rather than being dumped out into the content of the page as static strings.

$_SERVER['HTTP_REFERER'] and firefox

Just a quick note on a potentially useful discovery - if you need to keep track of the http referer and you're counting on using javascript (e.g. you might be writing an AJAX service), firefox doesn't pass the http_referer to a service when it gets (or posts) to it.

So if you were writing a service (say: something like a login overlay that returns the user to the last page they were viewing), you can 'resolve' the http referer from the javascript window.location.href. Useful to know, I think :)

Thursday 4 September 2008

Firebug detection note

Just a quick note that checking for window.console works if you need to detect the presence of firebug; if window.console is undefined, firebug is uninstalled or disabled. If firebug is enabled, alerting window.console should return [object Object]

Also, if firebug is enabled, alerting console.firebug will return the version number.

Wednesday 13 August 2008

Dojo: Event handling and the Firebug Console

I've spent some time working with dojo and looking at registering event listeners using dojo.connect. I then write the type of event out to firebug's console.

This example has been tested with the latest version of dojo at the time of writing (1.1.1) and Firebug 1.2.0b7

Wednesday 30 July 2008

Orbeon: 2 instances - copying XML content from one instance to another.

There was a problem that we needed to solve where the decisions made by the user would need to result in fragments of XML being copied / removed on request; for example, the choice(s) a user could make whilst filling in the XForm could result in specific (relevant) XML being moved from 'somewhere' into their instance document.

To do this, you will need some code that looks (something) like this:



Thanks once again to the Orbeon forums (http://www.nabble.com/ObjectWeb-OPS---Users-f2537.html) for helping me out once again with this one!

Hope this info helps someone else.

Tuesday 29 July 2008

Adding an eXist database as a Network Place.

A quick note (and reminder) for gaining access to your eXist database using Windows Explorer

Tools > Map Network Drive

Select the link that says: "Sign up for online storage or connect to a network server."

Hit Next >

Select 'Choose another network location' and hit Next >



Then give it a name.

You can now go to "My Network Places", find your mapping, put in the dba (or your user) name and password and you're good to go :)

Monday 12 May 2008

Orbeon example : Syntax for an if statement within an xf:output tag

In order to make Orbeon evaluate the contents of an instance and to respond based on an IF condition, here's some useful syntax.

The example below will output either 'Items' (for multiple items), or 'Item' for one item in an XML document:


Once again, thanks to the Orbeon forum for their assistance with this question:
http://www.nabble.com/ObjectWeb-OPS---Users-f2537.html

Friday 9 May 2008

Orbeon: Resolving Parameters to Load an XML Instance

Ok, so these are my notes regarding our method for getting Orbeon to load an instance based on some parameters that were sent to the XForm. This posting follows on from where my previous post left off:

In the model declaration of view.xhtml, I've created two minimal instances:



I'm also adding this piece in - as discussed in the last post - this resolves the get parameters and stores the information in the instance, so you can access the parameters using XPath:


We're initialising two ev:events; these fire at different times but both should have fired by the time the XForm has been rendered onscreen:



As the form loads, xforms-model-construct-done should fire first; xforms-ready should fire soon after that.

So here's the code for the first submission:



And here's similar code for the second submission - for the sake of example here, I'm using 2 parameters when calling this one...



Hope this helps someone.

Orbeon, inline XSLT and GET parameters

A couple of (hopefully) useful notes here -

If you're creating XForms and you're using Orbeon (which is a damn fine choice if you ask me ;)), then you may want to pass params to the form at some stage:

so you call your form using something like this:



To get at the values you pass in, you can do the following:

- Edit the page-flow.xml file in your folder, so you have something like this:



Note here that the default-submission refers to a file:
default-submission="/path-to-your/test.xml"

You'll need to create that XML structure, it can have no values or you can put values in there which will act as 'defaults'.

test.xml will look something like this:



in your view.xhtml, in the model, add something like this:



You can now XPath into your parameters using instance('my-params')/first and so on.

If you're using Orbeon 3.7 (either a nightly build or when it's released), you have the option to use the xxforms:get-request-parameter to grab the parameters and put them into an instance. To do this, first create an empty instance in your model:



And create an action (also in the model) like this:



If you call your form with an id parameter, you should find that xf:setvalue will write that request parameter into the params instance.

Finally, it may be the case that you need to fire an XSLT transform inside the view.xhtml. I've heard warnings that this can be expensive in terms of processing, but I found that the following code worked, so thought I'd make a note here.

In the body of your XForm, a block of code like this:


Will be executed by an XSLT processor. That example may be useful to someone.

Thanks go to everyone at the OPS forum http://www.nabble.com/ObjectWeb-OPS---Users-f2537.html who have been very helpful whenever I've had questions.

Thursday 17 April 2008

oXygen and NVDL with XForms - adding support for the class attribute

This may be useful to others too. I've been using oXygen to edit XForms for a while now and I've found the NVDL validation to be incredibly useful.

One of the things that was bugging me for a while was that the schema threw errors every time I used a class="{nameofyourclass}" attribute on any <xforms: ...> element.

As my XForms get bigger and more complex, it's become frustratingly difficult to see the 'serious' structural errors because of the number of errors that complained about me using class attributes. So with a slight schema modification, we can get NVDL to allow for the use of classes..

Edit the XForms-Schema.xsd in the frameworks\xforms folder of your Oxygen install and at around line 66 (for the schema that ships with Oxygen 8 and 9) you should see:



Below the line that says:


Add this:


Save and re-open Oxygen and your form. You'll need to have something like this at the top of your XForms document - where the NVDLSchema attribute will point to your install of oXygen:

Saturday 12 April 2008

Validating XForms Syntax with oXygen and NVDL

Adding this line:



To the top of your Xforms will cause the form to be validated using the standard oXygen NVDL schema - this aids the process of authoring valid XForms code by offering XForms-aware syntax highlighting and error checking. I have found this to be really useful, so I hope it helps others.

Note:
file:/C:/Program%20Files/Oxygen%20XML%20Editor%209/

This is the path for a default install of oXygen 9.1 for windows (C:\Program Files\Oxygen XML Editor 9\)

Using Orbeon with a "plain" theme

I've just noticed that you can load any orbeon forms with the following parameter:

?orbeon-theme=plain

To load the page without the Orbeon banner and navigation.

You can also make modifications to epilogue-servlet.xpl to create a case for specific pages. For example, I've created a page called xforms-submit and I want to load that page using the plain theme (theme-plain.xsl). Editing /config/epilogue-servlet.xpl (on line 56 in v 3.6.0) and adding this rule:



Achieves the desired effect.

So after adding this, my line looks like this:

Tuesday 25 March 2008

Two DOS/Windows tricks

From the commandline (in Windows)

net stop beep


Will stop the system bell.
See: http://nevcal.com/eclectic/beep_bleep.html

And typing title followed by a title name (e.g:)
title MY_APPLICATION

Will give the DOS window a more useful title.

Sunday 16 March 2008

Objective C in Ubuntu with GNUstep

I was following the Objective-C tutorial using GNUstep

http://gnustep.made-it.com/GSPT/xml/Tutorial_en.html

I had to install the following packages to make everything compile properly (from my history):

And in the GNUmakefile I added this path:


Hope this helps someone else get around any errors they initially encounter.

Thursday 14 February 2008

Deploying eXist 1.2 with the (Chiba) XFormsFilter

I had already installed eXist 1.2 and wanted to configure the chiba XFormsFilter - here are my notes for what I did to get the ant build script to work:

'wget' the jars you need for ant and junit and put them somewhere.

Set a few classpaths (I needed to do this in order to get things to work)



cd into the folder (e.g. /[YOUR_EXIST_BASE_DIR]/tools/XFormsFilter)

run:

ant -f build.xml build

And let it do it's stuff... Once that was done, I then copied the web.xml file into eXists WEB-INF folder (see the README file in the XFormsFilter doc folder for info).

Will do some more testing and maybe add more notes later..

Tuesday 5 February 2008

Using Saxon 9, Eclipse and Ant

I found this article whilst searching for a way to get Saxon 9 to step in and take control of xslt transforms inside Ant tasks:

http://www.saxonica.com/documentation/using-xsl/xsltfromant.html

The method outlined by Michael Kay looked like it was written for the commercial version of Saxon (SA).

Here's what I did to get Saxon 9B (the sourceforge edition) to work inside an ant task:

Blog Archive