Skip to main content

Posts

Showing posts from October, 2009

YSlow - Grade A - may not equate to a high performance website

YSlow, an add-on plugin for Firebug, a must have tool for all web developers concerned about performance of their website. As shown in the picture below, analysis using Firebug reveals all the the performance bottlenecks. YSlow, add-on plugin used along with Firebug, gives more detailed analysis and suggests useful tips to improve the performance. It has a grading system on a scale of A to F, A being the highest performer. Given below is the snapshot of its report run on this blog.

Amazon's RDS - Performance?

Majoriy of the typical application design warrants an Application server and database servers. The application servers interact with database server instance using connection/pooled connections. The interaction between app server and database server is highly I/O intensive and performance is good when these two instances(App server and DB) are on the same physical server or atleast better when they are on same LAN. Is it advisable having to rely on Relational Database Services from Amazon and an appserver running elsewhere? May be if the application runs on EC2 cloud and access Relational Database Services, it offers required performance. However, if we consider a small application, paying 11cents/hr for an EC2 instance and another 11 cents/hr for an RDS instance may be an expensive affair. If it is expensive for small applications what are the other scenarios where one can benifit from Amazon's Relational Database as Service? 1) If the application is a Client-Server based? (If th

Grails - cross-field Date validation - Method using controllers

In continuation of my earlier post on the cross-field date validation , I'm going to discuss another method using grails controller. The following code in "save" and "update" method of the controller validates the date fileds used in the student domain object that is discussed in the previous post def save = { def studentInstance = new Student (params) if (studentInstance.endDate.before(studentInstance.startDate)) { studentInstance.errors.rejectValue('endDate', 'student.endDate.shouldbegreater') } ... .. } Note that the code highlighted as bold is the addition to the boiler-plate code generated by using the grails command "grails generate-all" on the domain class "Student" Following message is to be added to the "messages.properties" file

Grails - cross-field Date validation

Often we run into domain classes with date fields. If the domain class has two datefields, startDate and endDate, and the rule for a valid combination is "endDate to be greater than startDate", how do we handle? I listed below two of the options, either using domain level constraints or using the domain classes. Option 1: Using domain constraints. Let us take a sample Grails Domain class class Student{ String name String school Date startDate Date endDate } Add the following constraints to enforce validation rules where name, school, startDate cannot be blank and endDate if present should be greater than startDate.

Grails - Jsecurity(Shiro) plugin usage

Jsecurity plugin for grails simplies some of the tasks related to application security. Ref: http://grails.org/JSecurity+Plugin If installed correctly, it installs few domain classes and an AuthController in your application. This topic will be helpful if you have successfully installed the jsecurity plugin and trying to explore more about the usage. The following domain classes are added. 1. JsecUser 2. JsecRole 3. JsecPermission etc There is one controller "AuthController" added to your list of controllers. If grails is installed on your local m/c and if your server is running on port 8080, you can invoke this controller using http://localhost:8080/myApp/auth We do not have to call this explicitly. Whenever there is request for a URL that is protected by JSecurity as configured in the "SecurityFilters", the controller is automatically invovoked. (Refer documentation plug-in )

Grails - replacing g:datepicker with gui:datepicker

A typical datepicker code that is generated for your domain classes is shown below: <g:datepicker name="dateOfJoin" value="${objInstance?.dateOfJoin}" /> Note: This code is autogenerated when you choose to create Controllers and Views by running the grails command "generate-all" for any domain class. It displays the Date, Month, year drop downs. Also it shows Drop downs to select Hrs and Mins. To remove the Hr and Mins dropdown a "precision" attribute should be used. <g:datepicker name="dateOfJoin" value="${obj?.dateOfJoin}" precision="day" /> To enable Null dates in your domain object The default datepicker options do not allow to choose a blank date.

grails - formatDate tag issue handling null date

I noticed an issue with the formatDate tag. It displays current date when the date passed is a null object when used in the gsp page. The default date is rendered along with timestamp when the gsp pages are generated using grails commands generate-views or generate-all for a domain class. The views (list.jsp and show.jsp) generated for the domain class contains the following code fragment. (Assuming your domain class has a variable declared as Date) ${fieldValue(bean:objectInstance, field:'expiryDate')} By using the formatDate tag as below we will be able to overcome the formatting issue. ${objectInstance?.expiryDate} However, I noticed that when expiryDate in the above example is null, the tag displays the current date as opposed to to showing blank.