Login
 

Polyglot Development Journal

 

Rapid Development in Java

A few folks asked me how I built the mobile version of this website. Thus, I wanted to describe the process in this article.

Background and Goals
My current website (Public-Action.org) is built with the PHP content manage system (CMS) Drupal. I could add new functionality to the Drupal CMS. However, I thought this would be good chance to extend some of my other skills.

I decided to generate a new mobile view-able version of my web content using Java. That gives me an opportunity to explore some of the newer computer languages which run on Java Virtual Machine (JVM). For example, Clojure or Scala.

A lot of shops have a large inventory of business requirements implemented in Java. To me. Java is still relevant as a computer language. However, newer programmers tend to be versed in other computer languages. Thus, an exploration of extending our basic process with a newer computer language seems worthy.

In this article. we'll produce the basic functionality used to create to exiting mobile version (view-able) of this site (public-action.org).

Building the mobile version of our website.
Our current website generates a Rich Site Summary (RSS) feed. RSS in an xml representation of the sites content. The current site's layout design is built to render on a full size (desktop/laptop) web browser. The site's layout is defined by the domain specific language (DSL), Cascading Style Sheets (CSS).

Thus, we need to replace the current CSS with CSS that responds and re-sizes to fit a mobile device. Again, we will use the responsive layout and design provided by the Twitter Bootstrap Front-end Framework.

Process Overview
I don't want a completely automated process. I want to manually inspect and verify the new mobile content (site) before publishing.

I need to get the mobile site up and running as soon as possible. That allows me to field test the site. My experience is, for mobile content, you literally need to take a walk with your device and see what your content looks like, how it renders when you are on the road.

Thus, we will rapidly prototype and build this application. I don't need a lot of bells and whistles. A plain command line utility fits my needs.

 

Welcome to Public Action

We build online communities.

That means we can build a brand new web site for you, customize your existing site, assist your current information system team. We have almost 30 years of experience in information systems, including business analysis, system design, application programming, database modeling. We also work with non-technical folks and give them a helping hand to get started.

Our specialty is working with

free software packages, allowing an individual, a community of users, or an enterprise to easily publish, manage and organize a wide variety of content on a website.".

We build custom software that meet your business requirements. We can also customize your existing information systems to better meet your needs.

 

Mobile Application Programmer Journal - JavaScript Introduction

Note! This the first installment of series on mobile development. This series will cover different strategies and techniques.

Why JavaScript?

I want to deliver an application via a web browser. Perhaps I've developed an application for a small group of folks. I want get the initial application out the door as quickly as possible. A web application (App) that runs within a web browser spares me the overhead of vendor specific devices, operating systems and stores.

As mentioned in the introduction above. A JavaScript web app is a strategy. Later in this series we'll discuss other strategies line native applications.

Doesn't JavaScript limit functionality? JavaScript running within a web browser?

Modern version of JavaScript along with HTML5 and CSS3 provide a lot more functionality than the original ECMAScript standard released in 1997.

HTML5 provides database to persist data across sessions (I.E. offline) in the client.

Offline Processing. In addition to embedded databases, the HTML5 "Application Cache" functions as an install kit for you web application's artifacts. In other words, once installed, you can run a stand alone application.

Our example application will demonstrate how to replace the server with the javascript engine/loader running inside the web browser. In a mobile environment, reducing your application to one javascript engine, via a single page architecture, is a critical performance gain.

Our example application will reproduce functions typically performed by the server. For example, we'll produce a new html document, and a "download link" all within the web browser.

File Access. Our project will demonstrate how we can read from and write to the client file system, just like a traditional desktop application.

CSS3 and HTML5 together deliver a rich user interface, cross-platform and light weight. We leverage the web browser to deliver the functionality.

 
 
 

Generate A Custom Drupal Module With Our Online Tool

Looking for a "Hello World" Drupal Module? Our new online tool wll generate a basic module for you. Simply fill out a quick form, hit submit and our tool will generate a complete module packaged as a compressed zip file

All you need to do is extract the custom module in the "sites/all/modules" directory of your Drupal installation.  Click here to start our online module generator.

Please read our article "Creating a Drupal Hello World Module" here, for more information.

 

Responsive Resume Project - Initial Release

Note, this articles is part of a series (here). In the previous installment we implemented data persistence. In this installment we complete our "must have" functions and thus, our initial release.

Logical Functions
These are the "must have" functions added for this installment.

  • Publish HTML Document. The user can now publish their resume as an html document.
  • Set Title (Web Browser Tab). The user can customize the document title text. This is the text that is displayed in the web browser tab control.
  • Move Row. The user can move a document row to a new location. For example, move the top row to the bottom of the document.

Other Enhancements
These are changes which enhance current functionality.

  • Toggle Edit Controls. The user can now turn the display of edit icons, on or off. The use can also turn the display of *cell borders, on or off. The user can preview the html document by hiding both edit icons and cell borders.
  • Changed popup dialog position. The popup dialogues now display in top right hand corner of the web browser's view area. The pop up dialogues now overlay the top navigation bar. The only exception is the "cell edit dialog".

*Note. I added an option to display cell borders to help the resume author visualize the rows and columns. The cells borders are not displayed in the published document. The cell borders are only displayed during the edit process (when the user toggles cell border on).

Implementation
The issue I struggled with the most was "how to get the Twitter Bootstrap style sheets in to our published document".

Normally, the Twitter Bootstrap CSS rules are stored in an external file (or remote URL/a file located on a remote web server ). Your document then references the Bootstrap CSS rules via a <link> tag (placed in the document head section). Separating a large set of CSS rules in an external file/remote URL, is typical way to organize your document's data.

Our use case is a little different. Our goal is to produce a single html document the user can email to someone.

If the receiver of the email wants to view the resume while off-line, then a remote URL reference is not going to work. For example, someone gets on an elevator which blocks wireless signals (I.E. the person's phone is no longer connected to the internet). We want that person on the elevator to be able to view the resume with the intended layout. If our resume document references a remote URL located across the internet, our elevator rider's mobile phone won't be able to reference the CSS rules. The result is, our document is not rendered as intended (it's missing the CSS rules). Thus, a reference to an a remote URL is not going to work.

Referencing a local external file, also conflicts with our use case. Our resume author would have to email 2 files. The 2 files would need to always be in the same location (on the recipient's computer/mobile device). That scenario is way too unpredictable, it's just not practical. Therefore, referencing a second, local external file is not an option.

Thus, I decided to copy the Twitter Bootstrap CSS rules in to the published resume html document (I.E. in the html head section).

We still had one more issue. How do we get the Twitter Bootstrap CSS rules in to our published resume document. This is actually more of a user experience (UX) issue. We don't want the resume author, to have to locate, and then select, the proper CSS file. We want to limit the number of steps the resume author has to take.

The challenge requires a little explanation.

Our program can not simply open a file from the local file system. The user must locate and select a file, using the browser's file dialog. The program can not select the file. The user must select the file.

To complicate matters, our program can not set the default location of the file dialog. In other words, the file dialog could start anywhere on the file system.

Remember, our resume author at the end of the publishing process, is going to have to select a destination location and optionally a destination file name. If in addition, the resume author has to select the CSS files, that adds up to, way too many steps.

Thus, I applied the same solution to our main program listing. Instead of storing the Twitter Bootstrap CSS rules in an external file, I store them in the head section of our webapp.html file (our main program file listing). That eliminates any file dialog requirements to obtain the CSS rules. A document can access it's own contents.

Thus, our application's file organization is little unusual, but it works. Sometimes, just getting it to work is good enough :)