Bhagwat Kumar

Groovy, Grails, Java, J2EE, Open Source, Agile enthusiast , Javascript frameworks, Big Data

Technology

Asynchronous behavior of AJAX

Ajax (shorthand for Asynchronous JavaScript and XML) is used to retrieve data from the server asynchronously without interfering with the display and behavior of the existing page. Forgetting this asynchronous behavior will produce incorrect result if it depends on the response from Ajax call. Lets take an example(I am using JQuery to...

14-Sep-2010

Grails

Criteria Query and pagination params

I have been using the following code to get paginated result and the total number of results returned irrespective of the pagination params. def result=SampleDomain.createCriteria().list(){ // multiple restrictions maxResults(params.max) firstResult(params.offset) } // Return type is ArrayList Integer ...

14-Jul-2010

Grails

Running multiple instances of a quartz job dynamically

I have been facing a problem of running configurable number of instances of the same job to consume the traffic that was varying over time. In order to dynamically create an instance of a job and run it immediately, I googled and found some interesting facts like each trigger is fired with a new instance of the job. We can create any no....

14-Jun-2010

Grails

List of fields in error of a domain instance

I have been working with domain and command object validation. I needed to get all the fields in error as a list so that I can display a single line error message like : please enter valid values in the following fields- filed1, field2. Another use case was to check the list of fields for error. Here is the code to get list of errorneous...

29-Apr-2010

Technology

Client side date validation using jQuery plugins

I have been facing problem of validating a text input field for a valid date. We are using two popular jquery plugins : jQuery validation and jQuery UI datepicker for client side validation. I googled it and found a good solution here http://stackoverflow.com/questions/511439/custom-date-format-with-jquery-validation-plugin but it was...

31-Mar-2010

Grails

Programmatically logging in user in jsecurity plugin

In our current project we are using jsecurity plugin and some of our bootstrap code required a user to be logged in. I found a nice blog http://www.tothenew.com/blog/?p=335 on this topic but it was using groovy metaprogramming to override the normal behaviour of SecurityUtils.getSubject() which is suitable for test environment. After...

04-Mar-2010

Technology

Monitoring ajax call response

Recently I have faced a problem of monitoring all the ajax calls. Based on the response from server I have to perform some task depending on the contents of response. If the html response contains some text input field, the first text input field should be automatically focused otherwise leave the response as it is. Here is the...

04-Mar-2010

Grails

Rescheduling a Quartz job programatically

In our current project on Grails we faced a problem  where we need to change the schedule of quartz job programmatically. The timeout value is read from the database. After doing some googling and digging mailing lists we found the following way- class MyJob{ static triggers = { simple name: 'mySimpleTrigger', group:...

01-Dec-2009

Technology

Ajax Request Progress Indicator

In my current project, I used ajax to fetch data from the server to provide experience like Desktop Application. I wanted to automatically show an indicator when an AJAX request is ongoing, and hide it when there is no such request. So I found the following solution for both the Prototype library and the JQuery library. Make sure the...

12-Oct-2009