發表文章

目前顯示的是 6月, 2012的文章

.NET – 在 ASP.NET MVC 3 中使用 Microsoft Chart Controls Library

圖片
Microsoft 提供了免費的 Chart Controls Library,其提供的範例都是 ASP.NET Web Form 的部份,需在 ASP.NET MVC 中使用的話又需使何設定呢?在此提供一個簡單的範例. 1. 在你的 MVC Web Project 中加入 System.Web.DataVisualization Library 2. 在 Web.config 中加入 assembly, httpHandlers 及 handlers. <?xml version="1.0" encoding="utf-8"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=152368 --> <configuration> <connectionStrings> <add name="xx" connectionString="user id=userId;data source=DBName;password=pwd;" /> </connectionStrings> <appSettings> <add key="webpages:Version" value="1.0.0.0" /> <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> </appSettings> <system.web> <compilation debug="true" targetFr...

Flex – Simple Animating Preloader

圖片
在 Flex 4 中並不提供 Busy Indicator Component 於 Application 中. 那在此提供一 Simple Preloader Component 以供參考. Source URL : http://flexdevtips.blogspot.tw/2011/05/simple-animating-preloader-and.html 1. Create Component 2. 在 MXML 中加入下面的程式碼 3. 在 creationComplete Handler 中加入下面二行程式碼 最後此 Component 提供 start(), stop() 二個 Method 讓此 Component Animating.

[轉貼]The Life Cycle of a Servlet

The Life Cycle of a Servlet This tutorial explains the Servlet interface and Servlet life cycle . A servlet example is given at the end which demonstrates the life cycle of a servlet. Servlets are managed components. They are managed by web container. Of the various responsibilities of web container, servlet life cycle management is the most important one. A servlet is managed through a well defined life cycle that defines how it is loaded, instantiated ad initialized, handles requests from clients and how it is taken out of service. The servlet life cycle methods are defined in the javax.servlet.Servlet interface of the Servlet API that all Servlets must implement directly or indirectly by extending GenericServlet or HttpServlet abstract classes. Most of the servlet you develop will implement it by extending HttpServlet class. The servlet life cycle methods defined in Servlet interface are init(), service() and destroy() . The life cycle starts when container instantiates the objec...

[轉貼]Understanding Servlet request

Understanding Servlet request ServletRequest Is one of the most important Interface of Servlet API. This tutorial explains the basics of ServletRequest interface and the most widely used methods defined in it. What is servlet request Servlets are designed to receive client request and generate responce to send to client. Though servlets are protocol independent, they are most widely used wih HTTP protocol to generate the dynamic response. The servlet request interface represents the request sent by the client (Browser in our case) . Whenever a web container receives a request from the browser, it creates a servlet request, and identifies which servlet needs to be invoked based on the URL mapping, calls the service method of the servlet and passes the servlet request object as parameter. The servlet request object contains information like request parameters, request headers etc. which is used by Servlet when generating the response. Javax.servlet.ServletRequest ServletRequest is an ...

[轉貼] Servlet File Upload Example

Java Servlet file upload example This Servlet File Upload tutorial explains how to handle the file upload in Servlets. This tutorial explains Handling file upload using apache commons-file file upload API. Handling file upload using commons file upload API The commons File Upload package makes it easy to add robust, high performance, file upload capacity to your Servlets and web applications. Download and install Commons File Upload package First of all, download the latest version of commons file upload package from here. FileUpload depends on Commons IO package, so download the version mentioned on the FileUpload dependency page. t the time of writing this tutorial, the latest version of Commons File Upload is 1.2.1 which depends on Commons IO version 1.3.2. Installation is very easy. Extract both of the downloaded zip files and put commons-fileupload-1.2.1.jar and commons-io-1.3.2.jar jar files into the WEB-INF/lib folded of your web application. The next step is to create t...

@MultipartConfig : Servlet 3.0 File Upload Example

@MultipartConfig : Servlet 3.0 File Upload Example Up to now Servlet API did not provide any built in support for handling file upload. we used various open source libraries like Commons file upload and COS multipart parser. However supporting file upload is so common requirement for any web application that Servlet 3.0 Specification supports it out of the box. Web container itself can parse the multipart request and make mime attachments available through HttpServletRequest object. A new annotation @MultiPartConfig has been introduced. When @MultiPartConfig is present on any servlet, it indicates that the servlet expects request of type multipart. @MultipartConfig annotation @MultipartConfig supports following attributes location - An absolute path to a directory on file system. It is important to remember that location doesnt support a path relative to application context. (I too don't know, why specification doesnt support context relative URLs). This location will be use...

讓所有 IE 支持 HTML5

自從 HTML 5能為我們的新網頁帶來更高效潔淨的code而得到更多關注,然而唯一能讓 IE 識別那些新元素則使用 html5.js 來解決 IE 支持 HTML5 的關題. html5.js 讓所有的 IE 支持 HTML5, html5.js 必須在頁面 head 元素內調用(因為 IE 必須在元素解析前知道這個元素,所以這個 js 文件不能在頁面底部調用). 你可以使用 IE 信件注釋來調用這個 js 文件,這樣像 FireFox 等非 IE 瀏覽器就會忽視這段 code。 <!--[if IE]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> < ![endif]-->

EasyUI – datebox 中如何自定日期格式化

在 datebox 中提供了二個 method ,一個為 formatter,另一個為 parser,這二個 method 是用來自定日期格式化的. formatter 是在顯示時如何選擇日期後將其格式化為所需的格式. parser 是在選擇好日期後告訴控件如何去解析自定義的格式. 將日期格式化為 yyyy-mm-dd 的格式如下所示: $('$dd').datebox({ formatter: function(date){ return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate(); }, parser: function(date){ return new Date(Date.parse(date.replace(/-/g,"/"))); } });

Hibernate – 呼叫 Stored Procedure 回傳 Cursor 時 Mapping Class Model

圖片
Hibernate 提供了強大的 OR Mapping 的功能,那如果呼叫 Stroed Procedure 回傳 Cursor 時,要如何使用 Hibernate 來 Mapping 至 Class Model 呢?下面提供一種方式已供參考. 1. 在 .hbm.xml 中定義 sql-query 的 name query’s name,然后就可以像調用一個命名的 HQL 查詢一樣直接調用命名 SQL 查詢.(Stored procedures are supported if the callable attribute is set) 2. 建立 mapping 的 Class Model 的 .hbm.xml 3. 在 Java 的程式碼就可以使用 getNamedQuery Method 指定 sql-query’s name 來取得所設定的 SQL,其 return cursor 時, Hibernate 則會自動的 Mapping 至 Class Model 中.

JavaScript – Date 提供 addDays 的 Method

在 JavaScript 中使用 Date Class 時,此部份並沒有提供 addDays 的 Method,那我們可以自行擴充 Custom Method,那在此提供一個簡單的 addDays Method 的擴充方法. 使用 prototype 的方式來擴充 Date 的 custom method,故即可在 Date Class 使用此 method. Date.prototype.addDays = function(days) { var dat = new Date(this.valueOf()); dat.setDate(dat.getDate() + days); return dat; };