Articles and News Blog - Tucanoo Solutions Ltd

A very small but I’m sure useful snippet here for anyone banging their head against a wall trying to figure out why they cannot validate command objects.. Or even why submitting a form they get this rather misleading exception message from Grails.

Method on class [com.tucanoo.SomeCommandObject] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.

This happens when you are using CommandObjects behind your forms, rather than binding directly to Domain objects. Don’t be tempted to avoid Command Objects, they are worth it and help keep your application more secure and maintainable.

I don’t know why a Grails IllegalStateException exception is thrown, but it happens when you are validating (maybe not even explicitly) a command object that is not explicitly marked as Validateable.

Simply mark your class with the annotation @Validateable and you should find the problem goes away.

It’s very easy to forget NOT to mark command objects @Validateable, perhaps they should be by default as certainly for me, I like to supply a whole bunch of constraints with my command objects and ensure they validate before I let the data contained within go near my domain layer.

The days of the static business website may be numbered as more and more businesses opt for a website using a CMS (content management system). Systems such as WordPress, Joomla and others are rapidly growing in popularity. What is it that makes CMS websites so much more attractive than conventional static websites? First lets look how Wikipedia define CMS and then cover the advantages provided by such a system.

Software system that provides website authoring, collaboration, and administration tools designed to allow users with little knowledge of web programming languages or markup languages to create and manage website content with relative ease. A robust CMS provides the foundation for collaboration, offering users the ability to manage documents and output for multiple author editing and participation. – Wikipedia

Content Management Systems

Content management systems provide a structure for your site, into which you or your web designer can put any content that you need. A CMS allows you to create, publish, edit and manage website content, as well as conducting site maintenance, from a central “control panel” page. Depending on which CMS you use, you may also be able to use the system to index content, process content submitted by other users and deploy content in a personalised way to your visitors — for example, by letting people select a custom skin or choose from different language options.

Content management systems are available to handle any kind of web content, from text, images and video to software applications. Content management systems also deliver content from a backend database, making them ideal for e-commerce sites that could potentially contain hundreds if not thousands of individual products. While some systems are commercial and require a fee, others (such as WordPress, Drupal, Joomla) are open-source and free for anyone to use.

 WordPress CMS for your business.  WordPress is an open source CMS, often used as a blog publishing application powered by PHP and MySQL:
 Drupal is a free software package that allows you to easily organize, manage and publish your content, with an endless variety of customization.

 Joomla is a content management system (CMS), which enables you to build Web sites and powerful online applications.

Coding

Traditional static websites must be coded in HTML and CSS before being uploaded to a server. The key advantage of a CMS site for many people is that little or no coding knowledge is necessary: the CMS software automatically renders the content into the appropriate code. This allows business people to take over the content and running of their websites directly, rather than being forced to outsource their sites, restrict themselves to only the most basic website functionality; or devote valuable time and resources to training staff or themselves in the coding skills required to build the sites they really want.

A CMS removes the technical hurdles that historically have impeded small business owners from building their own sites, giving you complete control over your own site and content and allowing you much more freedom in the range of content you can deploy.

 The WordPress log-in page can be customised to your own style, and allows multiple users to edit and upload content.
 The WordPress dashboard is user friendly rich in features and plugins that you can incorporate with your website

 This is an example post page within WordPress, you can edit and style your content and add additional feautures such as SEO, insert galleries and much much more.

Time Savings

Even for those who are skilled in coding websites can benefit from the time that a CMS can save. Using a CMS cuts down the time it takes to deploy content. Instead of having to spend countless hours coding the site from scratch or waiting for someone else to complete the code, a site based on a content management system lets you publish new content immediately. Although due to the fragmented nature of CMS template systems, the initial design of a bespoke CMS site will typically take longer to develop than a static website, the long term time savings of a CMS are not to be underrated.

CMS SEO

Another major advantage of CMS sites is that they make search engine optimisation much easier. Search engine optimisation is a collection of techniques that push your site further up the page when users search for particular words and phrases. Research has shown that most people do not bother to look at more than the first few results, let alone click through to the second page. This means that if your site is too far down the list, you won’t get the traffic you deserve. Your page ranking can make the difference between success or failure as a business — especially if your business relies on e-commerce. That’s where SEO comes in.

To optimise your page, you can add keyword-rich, good-quality text content, include keywords in the site’s code (meta tags) and tag images and videos on your site with appropriate keywords. All this is much easier on a CMS site. Even more important is refreshing your content. The more frequently your site is updated, the higher your page ranking will be; fresh content makes a site more valuable to visitors, so they tend to be ranked higher on Google and other search sites. Updating a conventional site regularly can be a chore, but with a CMS website it’s easy to amend existing content and upload new material.


If you have any questions regarding CMS systems or are considering moving from a static site to CMS based system, please do not hesitate to contact us and we’ll be happy to answer any questions you may have.

Read more ...

We are very happy to announce we have been commissioned to develop a very exciting project that’s causing a lot of buzz here at Tucanoo Towers. Without going into detail all I can say is we’ll be utilising Grails to develop a scalable back end service to complement a mobile app with social and business functionality.

I’d love to be able to give more juicy details away at this stage as what we’re working on has the potential to be HUGE… think FourSquare scale, then think bigger… but at this stage everything is under wraps and will be till close to product launch so watch this space…

With the extremely rapid rapid application development benefits provided by Grails,  It can be tempting to feel you have learned nearly everything you need to know by the time you’ve got your first web app up linked to a database with full CRUD facilities and error handling ready.  I’m sure you were as impressed with the speed of development as I was when I created my first Grails app.

At such a point it can be very tempting to just rush straight into your next project,  however you absolutely must continue your learning path and look over the excellent documentation  otherwise you be will missing out on some of the finer features provided by Grails and the Groovy language.

One feature I love and is the purpose of this article is Grails Metaprogramming.  It really makes a big difference for us Java programmers who can now add new functionality to already present classes very very quickly.

How many times have you thought oh I wish the String class had a truncate function built in for returning just a few characters of a long String with ellipses added if needed, or similar questions?

With MetaProgramming you can do just that, take the truncate() example ,   Apache Commons provide an abbreviate method in their StringUtils class which does the job perfectly, so if we could use that to do the work but also provide the ability to call it directly on  String class, ANYWHERE throughout our app, whether in GSP pages or controllers, services etc, all we need to do is dynamically add it to the String class in BootStrap.groovy like thus..

Another handy example that I’ve used frequently that comes to mind are Date objects, when used to represent date of births.  There have been many times it’s been required that the age of the ‘person’ or whatever the date of birth belongs to, is also displayed and used.

So just like we added the truncate method to String objects we can likewise add an age() method to Date objects.

Note in the above I am not defining expected parameters to be passed in as ‘delegate’ can always be assumed to be present, like ‘it’ in many cases.

So MetaProgramming, as you can see is a very powerful capability, limited by only our imagination as to what you can do yet can also easily be overlooked thanks to all the more immediately obvious benefits of Grails & Groovy.

Why not let us know what MetaProgramming additions you find you can’t live without

Read more ...