2010年3月19日 星期五

Devexpress's XtraGrid 客制顯示圖檔

1. 設定要顯示圖檔的欄位屬性
    FieldName 設為 "Image" 或其它值, 只要與其它的欄位值不相同就好
    UnboundType 設為 Object
    ColumnEdit 選擇 RepositoryItemPictureEdit 元件 (支援 Image 顯示)

2. 設定 XtraGrid 的 CustomUnboundColumnData Event Method

3. 在 CustomUnboundColumnData Method 內做處理
    Ex.
if (e.Column.FieldName == "Image" && e.IsGetData) { GridView view = sender as GridView; //取資料列欄位Path值 string path = (string)view.GetRowCellValue(e.RowHandle, "Path"); //取資料列欄位PhotoName值 string photoName = (string)view.GetRowCellValue(e.RowHandle, "PhotoName"); string photoNamePath = path + photoName; if (!Images.ContainsKey(photoNamePath)) { Image img = Image.FromFile(photoNamePath); Images.Add(photoNamePath, img); } e.Value = Images[photoNamePath];               }
4. 此方式將可以客制欄位的輸出值

2010年3月16日 星期二

Create Databases Command For MySql

利用 Command 建立 Databases

CREATE DATABASE [DatabasesName]
DEFAULT CHARACTER
SET utf8
COLLATE utf8_general_ci;

Ex.
  CREATE DATABASE TaipeiPotoAssociation
  DEFAULT CHARACTER
  SET utf8
  COLLATE utf8_general_ci;

2010年3月8日 星期一

Flex HttpService Cache 資料問題

最近因為Flex HttpService Cache困擾了很久
因為Cache的關係, 在Flex第一次 load 之後, 就不會再到後端 Server load 資料
會以第一次取回的資料做處理
目前找到比較好的解決方法
暫時在Url裡傳入一個隨機產生變數

Ex.
var _random:String=(Math.floor(Math.random()*10000000*10)>>0).toString();
        
authService = new HTTPService();
authService.url = "UserInfoAction.action";
authService.method = "POST";
authService.useProxy = false;
authService.resultFormat = "e4x";
var parameters:* =
{
  "random": _random
}      
authService.addEventListener(ResultEvent.RESULT, handleResult);      
authService.send(parameters); 
這樣子基本上可以先暫時解決 HttpService Cache 的問題

2010年3月3日 星期三

Use Servlet Download File

Source Code Refrence :

protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
      
request.setCharacterEncoding("UTF-8");

String filename = (String)request.getParameter("filename");
String original_filename = (String)request.getParameter("original_filename");
                ServletOutputStream op = response.getOutputStream();
                ServletContext context  = getServletConfig().getServletContext();
                String realFileNamePath = context.getRealPath(filename);
    
File f = new File(realFileNamePath);
                int length = 0;
  
                response.setContentType("application/octet-stream");
                response.setContentLength( (int)f.length() );
                response.setHeader( "Content-Disposition",
                                                      "attachment; filename=\"" + original_filename + "\"" );

               byte[] bbuf = new byte[1024];
               DataInputStream in = new DataInputStream(new FileInputStream(f));

               while ((in != null) && ((length = in.read(bbuf)) != -1))
               {
                     op.write(bbuf,0,length);
               }

               in.close();
               op.flush();
               op.close();
}

2010年3月2日 星期二

Tomcat Setting Server.xml's URIEncoding

like









let tomcat can parse UTF-8 URL