Sunday, 18 July 2010

Facebox load triggers second form submission

The problem
I encountered unexpected behaviour when attempting a basic form submit. When the form was submitted two calls to the server were made and two objects were created in the datastore.

Expected behaviour
The form's values are sent to the server associated with the /create URL, an object is created and persisted to the datastore and the application opens a page where the user can add additional information to the newly created object.

The form
<form id="create-form" action="/create" method="post">
  <fieldset>
    <legend>Create</legend>
    <label for="name-field">Name</label>
    <input id="name-field" name="name-field" type="text" value="" />

    <label for="tag-field">Tags</label>
    <input id="tag-field" name="tag-field" type="text" value="" />

    <input class="add-button" type="submit" value="Create" />
  </fieldset>
</form> 

The issue
While the behaviour was triggered by form submission, the issue was actually associated with  how the application rendered the view after submission. The page loaded after form submission included a Facebox. Facebox initialization causes a second set of requests on load. So, if posting to /create, Facebox will start a second set of requests with the base URL set to /create. A fix is to redirect to a URL which handles get requests after doing a post, in this way the server hit in the initial submission is not requested twice.

Wednesday, 24 March 2010

Kathy Sierra: creating a passionate developer


To mark Ada Lovelace Day, I'd like to 'give props' to Kathy Sierra, a woman whose approach to technology, learning and creativity has been a big part of my journey from historian to web developer.  As a younger woman I pursued an academic career in British gender and social history.  While I attained a PhD and was awarded a post-doctoral fellowship, job opportunities were very thin on the ground, not to mention located distressingly far from my partner.  So, in 2004 I determined that a new direction was called for, and decided to embark on a career in programming.  I should note that my partner, also from a humanities background, moved from linguistics to Java programming during the Dot Com Boom and his example was an important role model for me. 

My MSc in Information Techonology was an extremely challenging year, made worse by the fact that my instructors and fellow students understood the language of numbers and took a corresponding approach to programming.  I, on the other hand, had a good grasp of logic and of natural language and the writing process, but a shockingly poor conceptualisation of numbers, symbols which continue to 'short circuit' my brain.  Happily, I discovered Kathy's Head First series of Java learning guides.  The wit and humour of Head First helped me to excel in learning Java and Java for web applications; these books spoke to me in a way my instructors could not, and their innovative approach gave me an 'in' to the world of Java.  Kathy's passion for best practices and technology were inspiring and key to my ability to develop the initial skill set to pass my MSc with distinction, go out into the world as a Java developer and to then strike out on my own as an Internet entrepreneur working mainly in Python.

My metamorphoses from an historian to technologist was a painful one, but Kathy's fresh and unconventional approach to learning and her insights into Creating Passionate Users demonstrated to me in a very powerful way both that women 'belonged' in tech just as much as men and that working in technology was full of potential for fun and satisfying challenge.

Wednesday, 13 January 2010

Mac OSX application window won't maximize

I had an absolute nightmare with my Eclipse on Mac OSX 10.5.8, this morning, when, all of a sudden, the opened application window appeared as above.  As you can see the '+' button was obfuscated and there was no means of dragging open or expanding the window.  The main Mac header was available and I could, for instance, open an Eclipse search box, but could in no way expand the main window.

The problem: Mac doesn't support 'maximize'.  Using Google-fu, I sought keyboard shortcuts for 'maximize'.  This revealed to me that Mac does not support an equivalent 'maximize' functionality, as on Windows (I became a Mac user in Sept '09, so still finding my feet), and so keyboard shortcuts for 'maximize' are problematic and app-dependent.

The solution: Right Zoom from Blazing Tools. This sweet little piece of freeware installs quickly and allows you to Cmd + Option (alt) + E to 'maximize' the current application's window.  Saved my bacon and stopped me having to reinstall my whole development environment. Whoop!