Archive for November 2008

 
 

Disable Form Submit from Pressing ‘Enter’ in Text Field

Just a note of jQuery fragment.

// cancel the default event action for input and move to the next element
jQuery('input').keydown(function(e){
    if (e.keyCode == 13 && (e.target.type == 'text' || e.target.type == 'password')){
        var elements = jQuery(this).parents('form').get(0).elements;
        var i = 0;
        for (; i < elements.length; i++) {
            if (elements[i] == e.target){
                break;
            }
       }
       e.preventDefault();//this is what doing the trick...
       jQuery(elements[i + 1]).focus();
   }
});

Spring ResourceBundleMessageSource Issue

Problem:

  • After configuring messageSource with ResourceBundleMessageSource, messages output by webApplicationContext.getMessage are in wrong language version. But this issue doesn’t appear in spring message tag.

Solution:

Replace ResourceBundleMessageSource with ReloadableResourceBundleMessageSource, add property fallbackToSystemLocale and set to false.

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="fallbackToSystemLocale" value="false"/>
    <property name="basenames">
        <list>
            <value>classpath:messages</value>
        </list>
    </property>
</bean>

Refer to: http://day-to-day-stuff.blogspot.com/2008/07/spring-message-resource-weirdness.html

Prevent double submit a form using jQuery

jQuery(document).ready(function(){
    jQuery('form').submit(function(e){
        jQuery(this).find('input[@type=submit],button[@type=submit]').attr('disable', 'true').css('color', '#ddd').css('background', '#aaa');
    })
}

Fix for PNG issue in IE6

Well known issus that IE6 can not display transparency for PNG picture. But now here comes the IFixPNG from http://jquery.khurshid.com/ifixpng.php. It’s really a perfect fix for this issue…

Icon Themes from Wikimedia

The most commonly seen icon collections are free from WikiMedia!

http://commons.wikimedia.org/wiki/Category:Icons_themes

SQL Sample for MSSQL

select * from SYSOBJECTS  where TYPE = 'U' order by NAME

equals to the one in mysql

show tables

Or we can use sp_help, for exmple:

exec sp_help database_name

refer to http://msdn.microsoft.com/en-us/library/aa933429.aspx