2011年8月25日 星期四
DIV讓超出高度的文字隱藏
<div style="position: relative;overflow: hidden;height:45px;margin-top:0px;word-wrap:break-word;word-break:break-all;">
將comparator 寫在Collections.sort裡面
List<TreemallNewCycleBannerVO> list = new ArrayList<TreemallNewCycleBannerVO>(cycleBannerTempMap.values());
Collections.sort(list, new Comparator<TreemallNewCycleBannerVO>() {
public int compare(TreemallNewCycleBannerVO o1,TreemallNewCycleBannerVO o2) {
Integer priority1 = Integer.parseInt(o1.getPriority());
Integer priority2 = Integer.parseInt(o2.getPriority());
return (priority1<priority2 ? -1 : (priority1==priority2 ? 0 : 1));
}
});
Collections.sort(list, new Comparator<TreemallNewCycleBannerVO>() {
public int compare(TreemallNewCycleBannerVO o1,TreemallNewCycleBannerVO o2) {
Integer priority1 = Integer.parseInt(o1.getPriority());
Integer priority2 = Integer.parseInt(o2.getPriority());
return (priority1<priority2 ? -1 : (priority1==priority2 ? 0 : 1));
}
});
2011年7月27日 星期三
JAVA美國數字格式
NumberFormat usFormat = NumberFormat.getIntegerInstance(Locale.US);
//使用美國格式
String number = usFormat.format(1000)
//將1000轉為美國格式
System.out.println(number);
//結果1,000
//使用美國格式
String number = usFormat.format(1000)
//將1000轉為美國格式
System.out.println(number);
//結果1,000
URLConnection應用,與遠端做資料溝通
//傳送物件到遠端
URL url = new URL("遠端網址");
URLConnection urlConnection = url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.setUseCaches(false);
urlConnection.setDefaultUseCaches(false);
urlConnection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
ObjectOutputStream ous = new ObjectOutputStream(urlConnection.getOutputStream());
ous.writeObject(cgsNums);
ous.writeObject(qcOrders);
ous.writeObject(cpdtOwner);
ous.flush();
ous.close();
//遠端將資料組合後
//讀取網頁
StringBuffer html = new StringBuffer();
BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String inputLine;
while ((inputLine = br.readLine()) != null) {
html.append(inputLine).append("\r\n");
}
URL url = new URL("遠端網址");
URLConnection urlConnection = url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.setUseCaches(false);
urlConnection.setDefaultUseCaches(false);
urlConnection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
ObjectOutputStream ous = new ObjectOutputStream(urlConnection.getOutputStream());
ous.writeObject(cgsNums);
ous.writeObject(qcOrders);
ous.writeObject(cpdtOwner);
ous.flush();
ous.close();
//遠端將資料組合後
//讀取網頁
StringBuffer html = new StringBuffer();
BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String inputLine;
while ((inputLine = br.readLine()) != null) {
html.append(inputLine).append("\r\n");
}
2011年7月25日 星期一
JQuery checkbox 應用
每次都忘記JQuery對checkbox操作的寫法,下定決心把他寫起來
取得已勾選的數量
$('input[type=checkbox][name=cpdtNum]:checked').length
檢查checkbox使否已被勾選
$(obj).is(':checked')
取得已勾選的數量
$('input[type=checkbox][name=cpdtNum]:checked').length
檢查checkbox使否已被勾選
$(obj).is(':checked')
訂閱:
文章 (Atom)