หน้าเว็บ

วันอังคารที่ 15 ตุลาคม พ.ศ. 2556

Spring autowire all implementations which implements an interface

interface
สร้าง interface ขึ้นมา ในที่นี้ชื่อว่า Worker

Worker.java
package com.blogspot.na5cent.app.service;

/**
 *
 * @author redcrow
 */
public interface Worker {
    
    public void working();
}
implementations 
สร้าง Worker[n] implementation ซึ่ง implements an interface Worker
ในที่นี้ประกอบไปด้วย Worker1, Worker2, Worker3
การทำงานแต่ละตัวคือให้ log class name ของตัวเองออกมา

วันจันทร์ที่ 14 ตุลาคม พ.ศ. 2556

html meta tag no cache

<head>
    ....
    ....

    <meta http-equiv="cache-control" content="max-age=0" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="expires" content="0" />
    <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
    <meta http-equiv="pragma" content="no-cache" />

    ....
    ....
</head>
thank you : http://stackoverflow.com/questions/1341089/using-meta-tags-to-turn-off-caching-in-all-browsers

วันอังคารที่ 8 ตุลาคม พ.ศ. 2556

jQuery keypress delay

var $input = $('.input-form');
var timeoutReference;

$input.keypress(function(){
  if(timeoutReference){
    window.clearTimeout(timeoutReference);
  }
 
  timeoutReference = setTimeout(function(){
    window.clearTimeout(timeoutReference);
  
    //your code ...
  
  }, 300);
});

วันอาทิตย์ที่ 6 ตุลาคม พ.ศ. 2556

jsf timezone

in view
....
<f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" locale="en" timeZone="GTM+7" />
....
timeZone="GTM+7" is Bangkok, Hanoi, Jakarta

OR

set Locale timezone  (web.xml)
...
...
...
    <context-param>
        <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
        <param-value>true</param-value>
    </context-param>
...
...
...

วันพุธที่ 2 ตุลาคม พ.ศ. 2556

Lazy load attribute Entity class JPA

Staff.java
...
import javax.persistence.Basic;
...
...
...

@Entity
@Table(name = "Staff")
public class Staff implements Serializable{
    ....
    ....
    ....
    @Lob
    @Basic(fetch = FetchType.LAZY) //****
    private byte[] image;
}