Return to Jive Software

I was able to corner Josh Bancroft, Intel Social Media Evangelist, at a recent blogger dinner at the Jive Software offices (co-sponsored by Intel, but organized by the Portland blogging community). In this video, Josh discusses Facebook, hype around social networks that do not exist, and living life online.

 

 

Or click here to download.

2,202 Views 0 Comments Permalink Tags: portland, jive_software, community, podcast, bloggers, bloggers

The Switch to Freemarker

Posted by Nick Hill Jul 20, 2007

Where are all the JSP's? That is a question we have been hearing a lot lately, after deciding that the view layer of Clearspace would be built on an open alternative to JSP, Freemarker. What is Freemarker? Freemarker is simply a "template engine"; a generic tool to generate text output based on tempaltes. The next question that usually follows: Why?

 

Common problems with JSP

  • Java code is too tempting, even though it is considered bad design to mix presentation with core logic, everyone knowingly does it.

  • Java code is required to do mundane things, such as <a href="<%= request.getContextPath() %>/index.html">Home page</a>

  • Simple tasks are difficult, such as escaping html, or formatting a date

  • Looping is verbose, awkward and messy

  • Bad exception handling, printing out things like NullPointerExceptions to the user

  • Need a compiler and any change needs to be recompiled.

  • Various application server bugs. We have recently run into a few problems on 'unnamed' application servers where  the jsp's are created importing the servlet package without fully qualifying names, This causes us to have class name problems.

 

Freemarker as an alternative

 

To fully realize the benefits of the MVC Pattern, a true separation of Java Code (the controller) and the HTML (the view) is required. Using a template engine, such as Freemarker, as your view will solve many of the problems listed above. The underlying design will be cleaner, the syntax clearer, the error messages more meaningful, and the application more customizable.

 

Also, Unlike JSP, FreeMarker templates are completely independent of the file format; they can just as easily be used to create an HTML file, XML file, CSS file, JavaScript file, even a plain text file. In fact, FreeMarker is independent of servlets altogether, making it just as useful on the client as on the server.

 

As an example of how Freemarker can cleanup your view pages, lets take one line of JSP and convert it to freemarker:

 

JSP

Freemarker

<% Action action = ActionUtils.getAction(); %>

<input type="text" name="subject"

value="<%= action.getSubject() != null ? StringUtils.escapeHTMLTags(action.getSubject()) : "" %> "/>

<input type="text" name="subject"

value="${subject!?html}"/>

 

Interesting Clearspace features relating to Freemarker

  • Themes: To help facilitate our customer's need to customize the look and feel of our products, we wrote a feature that provides our customer's the ability to customize most front end pages directly from the admin console without having to make a single change to the source code or even restart the application server. Simply select the page you want to customize and edit the template. Additionally, these custom pages can be grouped into different "Themes" and mapped to a commuity, a forum, even a URL pattern. This type of flexible UI would not be possible with JSP's. Freemarker provides us the ability to load the source of a template from a number of places, including a remote server, and without ever needing to be recompiled.

  • Community Everywhere: If you want to make some dynamic HTML content available on any remote site, such as displaying a Clearspace thread at the bottom of a remote article, all you have to do is process the freemarker template that contains the thread HTML, wrap it in document.write(result); and return contentType text/javascript.

  • Freemarker Email Templates: Allows for easily customizable dynamic emails with very detailed and useful information.

 

After using Freemarker for some time, we can definitely say that it is a template language we?re confident in. We found it to be the easiest to use, learn and the most powerful while still having a clean, simple syntax. For a comparision with velocity, check out Freemarker vs. Velocity. We?ve also found that any good JSP programmer finds Freemarker enjoyable to use and learn. The one downside is that we all use Intellij Idea for development and there is currently no Freemarker support.

 

For those who still are not convinced, rest assured that it is still possible to make customizations to the application using only JSP's.

 

To learn more, check out FreeMarker: An open alternative to JSP

2,119 Views 1 Comments Permalink Tags: clearspacex, clearspace, themes, freemarker, ui, jsp

We have always been committed to making the user experience as painless as possible. Our goal has always been to create products that are incredibly easy to setup and administer; however, we went without developing an upgrade framework for some time.

 

Why did we wait until now? Well, because upgrades are generally viewed as a "one time" thing and we always had more demanding feature requests.  When we embarked on building Clearspace however, we knew from the start that building an upgrade framework would be a valuable investment, and help us reach the goal of making upgrades painless for both our existing and our rapidly growing customer base.

 

We knew that we needed a tool that did more than execute simple SQL scripts. We knew that it needed to be as robust as our setup tool. That means that it needed to be secure by requiring a system administrator to authenticate, concise by prompting the user that an upgrade needs to take place, and informative by alerting the user if a task has failed for any reason and providing them with the ability to manually perform that task.

 

  

 

 

You know that feeling when you get something free? Whether it is a free Ipod with your new Macbook Pro, or simply a free sample at Costco, it's a good feeling. Having developed this upgrade framework with the mindset of making our customer's lives easier, we quickly found many other benefits of having developed an upgrade framework:

 

Improves the user experience by allowing painless automated upgrades.

 

Customers no longer have to pour through documentation and gain access to their database administrators to execute scripts. The system will automatically determine which version is installed and perform all necessary upgrade tasks. Customers will be more willing to upgrade to new releases, which will result in reduced support costs and increased revenues.

 

Enhances the development process

 

How many times have you updated from version control and no longer been able to start up the application because of some changes made by another developer? How many times have you been working on a project when you receive an email from one of your team members saying that table xyz has been changed and all the developers need to execute some script? This unnecessary frustration and cost of development is solved with the upgrade framework and helps to decrease the cost of development.

 

Manages exact changes between versions

 

As a developer, I generally can not remember all the changes I made last week, let alone last month.  Unless you are highly disciplined and you keep notes of every major change you have made, you will likely miss something when it comes time to worry about upgrades. By writing an upgrade task when you make a change, you are effectively documenting your changes and will be ready to go when it is time to release.

 

Allows for demo servers to be up running during development

 

Having a demo server up for the company to use during development is beneficial in many ways. It allows your company to 'eat its own dog food' and test the functionality and usability of an application months before the beta process. However, managing the state of a demo server during development can be a daunting task. Not if you have an automated upgrade framework. Day to day changes will be picked up and your demo server will always be the latest and greatest.

 

 

Lowers the support burden for new releases and upgrade

 

When upgrades go smoothly, the cost of upgrading is lowered for both the customer and the company.

 

Improves the productivity of the Professional Services Department

 

Having previously worked in our professional services department, I know first hand how managing various projects can be difficult. Having an upgrade framework facilitates the process of making customizations to the core product. Not to mention two years down the road when the customer wants to upgrade the core product and keep their customizations.

 

 

Enables plugins to provide their own upgrade path.

 

Similar to customizations made by the professional services department, having the ability to provide automated plugin specific upgrade paths is insanely powerful.

 

For any of you looking to justify investing in an upgrade framework, it has been our experience that an upgrade framework will benefit everyone involved, and will pay for itself in a matter of weeks. In fact, I would go so far as to say that developing an automated upgrade framework is as essential a practice for enterprise applications as unit testing.

1,156 Views 7 Comments Permalink