As we know, Hibernate Query Language or using GORM are not enough, for example if we want to create complex queries or using native sql functions ie. date() function in MySQL. That’s why we need to use Groovy SQL to achive that.
Read the rest of this entry »

jasper report
Dynamic Jasper Report is such a nice thing that exists in this world. You can create a report using powerfull Jasper Engine without creating a jrxml first. You don’t need iReport anymore. Actually I hate using iReport, it is not fun for me
Read the rest of this entry »
It is released new version for open flash chart for Grails.
the tutorial was on http://mybytes.wordpress.com/
The difference is that 0.6 using OFC version 2 and 0.5 still using version 1. Version 2 is not compatible with version 1 so please watch out when you tried to update that plugin.
More information about Open Flash Chart 2, check the maker web on http://teethgrinder.co.uk/open-flash-chart-2/
Here is a little tips to let grails create using innodb engine on mysql, everytime grails create a domain/table.
1
2
3
4
5
6
7
| dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
username = "wysmedia"
password = "password"
dialect = org.hibernate.dialect.MySQLInnoDBDialect
} |
dialect = org.hibernate.dialect.MySQLInnoDBDialect that’s the main idea to set mysql using innodb. With InnoDB you can use service transaction or database transaction
Yesterday I got a headache problem with a checkbox. I wrote like this on GSP
1
2
3
4
5
6
| <g:form action="save">
... table ...
<g:checkBox name="myCheckbox" value="" />
... other element ...
<input type='submit' value='Save'/>
</g:form> |
did you know what the happened ? myCheckbox always returned empty or null value everytime I saved the form. I thought Grails has bug at first, I did check and create a checkbox using scaffold and I found that value=”" makes the null value everytime I saved the form
The solution was simple enough:
1
2
3
4
5
6
| <g:form action="save">
... table ...
<g:checkBox name="myCheckbox"/>
... other element ...
<input type='submit' value='Save'/>
</g:form> |
Just eliminate value=”" and it all solved. I learned that using value=”somethingHere” can be useful if we want to save a value into our database. I hope my tricks can save you from headache. Be aware of checkbox .. hahaha…
Sometimes we found that our server are not behave normal, like there are bugs or server produce runtime exception (or error 404 etc). Those exception are not returned by ajax. So it will keep hidden and seems nothing happened. But if you have firebug installed, you can found that there are errors happened from your server.
So here is how you can trap all errors and displayed on your screen (without using firebug).
This example works on grails main layout (but you can use this tips on any programming language, just put this code on main layout). My code using Jquery and JQalert to display the error
1
2
3
4
5
6
7
| $(document).ready(function(){
$(document).ajaxError(function(event, request, setting){
var re = /<br\/>|<br>/g; // for replacing all <br/> with empty string in error 404
var txt = request.responseText.replace(re,"");
jqalert(txt,"Server Error");
});
}); |
Sometimes, we need to refactor our domain / database table. For example, our first domain looks like this :
1
2
3
4
| class Person {
String personName ;
BigDecimal monthlyIncome ;
} |
Now we want to eliminate/change the monthlyIncome and replace it with BigDecimal weeklyIncome
we type
1
2
3
4
| class Person {
String personName ;
BigDecimal weeklyIncome;
} |
But, when we look at the table, it still have monthlyIncome field. That’s why we need to eliminate it. If we works as a team, this could be a messy and troublesome, because monthlyIncome is not nullable. So it produce error (JDBC errors) when someone tried to update or save into that table.
That’s why we need Autobase for this dirty job. Autobase is Grails plugin that created base on Liquibase. Liquibase, however using xml format to do database migration. I hate to write on xml actually.
Luckily, Robert Fischer, wrote this useful Grails’s plugin, so that we can write it using Groovy DSL.
Read the rest of this entry »
Recent Comments