Archive for the ‘Web programming’ Category

Wicket – Sending a 301 redirect

This post describes how to send a HTTP 301 redirect in the Java Wicket Framework.
HTTP redirect intro
There are two types of HTTP redirects:
-”HTTP 1.1 301 Moved Permanently”
-”HTTP 1.1 302 Found”, previously called “HTTP 1.1 302 Moved Temporarily”
A 301 indicates that the requested resource has been assigned a new permanent URI and any [...]

Grails vs. Rails

Ruby On Rails and Grails are two popular MVC webframeworks. Rails uses the Ruby language, and Grails uses Groovy. In this post I compare Grails vs Rails.
Introduction
Ruby On Rails (in short just “Rails”) is a webframework that uses the Ruby language. It uses a push MVC design pattern, which means that a controller/action receives a [...]

Shorter Grails textField

Making textFields in Grails is a bit verbose, at least if you want error highlighting and returned values on errors. This post shows a quick solution.
Problem
A full textField would be:
<g:textField class="${hasErrors(bean:user, field:'name', 'errors')}" value="${fieldValue(bean:user,field:'name')}" name="name"/>
Which clearly is very verbose; you have to specify “user” twice, and “name” even three times. This verbosity also makes the [...]

Grails and existing Java Hibernate DAO’s

If you have some existing Java Hibernate entity classes (outside Grails), you only have to add one line in Datasource config, and you can use them immediately. However, if you have some exising POJO (Plain Old Java Object) Hibernate DAO’s (classes that implement a Data Access Object pattern), you’ll have to do some additional steps [...]

Struts2 table annoyance

I was trying out a bit of Struts 2 just to test it out. An annoyance that quickly came up is that the HTML layout of forms are all table based. For example, if you want an input field for your name, then a column-based HTML table will be created automatically for that. The first [...]

Seam-gen and default ROOT context

If you are using seam-gen to deploy webapps as war-files to a webserver (for example JBoss AS), the root url of your webapp will be something like http://example.com/myproject/. (Where “myproject” is the name that you gave to your webapps when setting it up using seam-gen.) If you want your webapp to be assigned to the root [...]

JSF doesn’t validate empty forms

Error:
Caused by org.hibernate.validator.InvalidStateException with message: “validation failed for: MyHibernateEntity”
Are you getting this error while trying to validate a form with empty fields using Seam, JSF and Hibernate? Then read on.
Seam allows you to define validation conditions on a single place: on the Hibernate / JPA entities. And then use this condition in the view without [...]

Seam and URL rewriting with parameters and forms

Making pretty bookmarkable RESTful URLs in JSF is hard. Fortunately the Seam framework solves this problem by supporting HTTP parameters, advanced page navigation, and can use the help of UrlRewriteFilter. But making bookmarkable parameter URLs in combination with a POST form can still be a bit tricky. This blog post shows an example how to solve this [...]