<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    2006年3月20日

    在IBM的JDK環境下進行JVM內存監控的問題

    錯誤信息如下:
    java.lang.NoClassDefFoundError: sun.management.ManagementFactory

    處理:

    sun.management.ManagementFactory替換成java.lang.management.ManagementFactory  

    因為ibmjdk沒有sun.management.ManagementFactory這個對象

    posted @ 2010-11-25 12:01 JGAO編程隨筆 閱讀(561) | 評論 (0)編輯 收藏

    oracel PreparedStatement的setString問題

    錯誤信息如下:

    超過最大長度限制

    處理:

    只能插入666個中文字符。


    或者更新到最新的
    oracle驅動包

    posted @ 2010-11-25 12:00 JGAO編程隨筆 閱讀(266) | 評論 (0)編輯 收藏

    servicemix部署到websphere中,需注意的問題

    1derby.jar包可能沖突,需刪除項目中的該包

    2MBean調用問題

       Websphere的MBean注冊路徑包括cell,nodeName和processName,具體可以銅鼓jconsole連接來查看MBean注冊的全路徑。這三個值可以通過Websphere的com.ibm.websphere.management.AdminServiceFactory這個對象來獲取,spring中的配置如下:
    <!-- 用于獲取websphereMBean名稱的cell,node,process -->

    <bean id="adminService" class="com.ibm.websphere.management.AdminServiceFactory" factory-method="getAdminService"/>

    <bean id="adminService.cellName" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>

    <bean id="adminService.nodeName" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>

    <bean id="adminService.processName" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>

    <bean id="websphereNamingStrategy" class="com.des.engine.mbean.WebsphereNamingStrategy">

    <property name="cellName" ref="adminService.cellName"/>

    <property name="nodeName" ref="adminService.nodeName"/>

    <property name="processName" ref="adminService.processName"/>

    </bean>

    WebsphereNamingStrategy為自己創建的對象就包括那三個屬性

    3:安全問題

    出現如下錯誤,Caused by: javax.management.JMRuntimeException: ADMN0022E: 由于憑證不足或憑證為空,無法對 org.apache.servicemix:Name=ServiceMgtImpl,cell=dvpbNode02Cell,Type=SystemService,ContainerName=ServiceMix,node=dvpbNode02,process=server1 MBean  retrieveServiceList 操作進行訪問。

        該問題是因為設置了安全控制,把控制臺的【安全性->安全管理、應用程序和基礎結構】里面的所以安全配置都去掉,然后重新啟動服務器主機(注意是重啟主機,不然安全設置不起作用),再啟動websphere服務應該就可以了,還有就是servicemix的應用要跟websphere一起啟動,不要等websphere啟動后再到控制臺啟動

    posted @ 2010-11-25 11:58 JGAO編程隨筆 閱讀(888) | 評論 (2)編輯 收藏

    ResultSet內存溢出OutOfMemory問題

    錯誤信息如下:

    jdbc在操作oracle海量數據的時候用ResultSet獲取所有的返回數據出現內存溢出

    處理:
    出錯的原因是ResultSet用的是可滾動結果集,正常情況下ResultSet是指針指向數據庫的數據,本身是不存儲數據庫的數據的,默認情況下就算是提交的sql能查詢處上億條的數據也是不消耗內存的,但是如果用的是可滾動結果集的ResultSet情況就不一樣了,ORACLE 是不支持可滾動結果集的,那么我們用JDBC得到一個可滾動的結果集就是由JDBC自己支持的,也就是說結果集是要存放在內存中的,所以在海量數據的情況下也就是要消耗大量內存的,因此造成內存溢出也就是正常的了,所以如果是海量數據的話就不要用可滾動結果集就可以了。

    posted @ 2009-06-23 21:19 JGAO編程隨筆 閱讀(2107) | 評論 (0)編輯 收藏

    com.ibm.websphere.ce.cm.StaleConnectionException: [ibm][db2][jcc][t4][2030][11211] 檢測到了通信錯誤

    錯誤信息如下:

    com.ibm.websphere.ce.cm.StaleConnectionException: [ibm][db2][jcc][t4][2030][11211]

    檢測到了通信錯誤。所使用的通信協議:TCP/IP"n所使用的通信 APISOCKETS

    檢測到錯誤的位置:Reply.fill()"n用于檢測錯誤的通信功能:InputStream.read()

    特定于協議的錯誤代碼數據不足、 0。消息:null"n   

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)"n     

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:67)"n    at

    sun.reflect.DelegatingConstructorAccessorImpl.newInstance

    (DelegatingConstructorAccessorImpl.java:45)"n

    at java.lang.reflect.Constructor.newInstance(Constructor.java:522)"n  

    at com.ibm.websphere.rsadapter.GenericDataStoreHelper.mapExceptionHelper

    (GenericDataStoreHelper.java:523)"n   

    at com.ibm.websphere.rsadapter.GenericDataStoreHelper.mapException(GenericDataStoreHelper.java:578)"n      

    at com.ibm.ws.rsadapter.jdbc.WSJdbcUtil.mapException(WSJdbcUtil.java:909)"n 

    at com.ibm.ws.rsadapter.jdbc.WSJdbcStatement.executeQuery(WSJdbcStatement.java:898)"n   

    at com.newland.bi.util.db.DBUtil.executeQuery(Unknown Source)"n

    at com.newland.bi.util.db.DBUtil.executeSql(Unknown Source)"n     

    at com.newland.bi.dao.jdbc.DaoImpl.executeQuery(DaoImpl.java:64)"n   

    at com.newland.bi.service.report.exp.dao.ReportExpDao.getExpList(ReportExpDao.java:72)"n 

    at com.newland.bi.service.report.exp.manage.ReportExpMgt.runExport(ReportExpMgt.java:91)"n   

    at com.newland.bi.service.report.exp.servlet.ReportExp1Servlet$1.run(ReportExp1Servlet.java:97)"n      

    at java.util.TimerThread.mainLoop(Timer.java:537)"n       at java.util.TimerThread.run(Timer.java:487)"n

    處理:

    出錯的原因可能是防火墻問題,websphere應用服務器和數據庫服務器之間是否存在防火墻

    防火墻是否會設置多久沒活動的連接就自動斷開掉,如果是這樣的話就會有問題,因為websphere上面的數據庫連接池可能有一段時間沒連接而被防火墻斷掉了

    但對于連接池本身根本就不知道該連接是否還可用,所以web應用從連接池獲取的連接可能就是已經斷開的了,所以就可能會出現日記中的錯誤問題


     

    posted @ 2009-06-23 21:14 JGAO編程隨筆 閱讀(7421) | 評論 (1)編輯 收藏

    Timer.schedule和Timer.scheduleAtFixedRate的區別

    schedulescheduleAtFixedRate的區別在于,如果指定開始執行的時間在當前系統運行時間之前,scheduleAtFixedRate會把已經過去的時間也作為周期執行,而schedule不會把過去的時間算上。

    posted @ 2009-06-23 21:13 JGAO編程隨筆 閱讀(1000) | 評論 (0)編輯 收藏

    cxf找不到類org.apache.axis.soap.MessageFactoryImpl出錯

     

    錯誤信息如下:

    Caused by: java.lang.ClassNotFoundException: org.apache.axis.soap.MessageFactoryImpl

        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

        at javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:50)

        ... 10 more

    處理:

    原因是調用了axis soap.MessageFactoryImpl,cxf應該用的是sun
         在注冊安全攔截器之前執行下面代碼就可以了

    System.setProperty("javax.xml.soap.MessageFactory", "com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl");

    posted @ 2009-06-23 21:10 JGAO編程隨筆 閱讀(1276) | 評論 (0)編輯 收藏

    瀏覽器下載txt文件問題

    我們寫程序的時候可能會想用open或者<a>來下載一個txt文件,但我們會發現我們用瀏覽器下載這個txt文件的時候老是在瀏覽器里面直接打開了,而不是提示下載,這樣的話如果txt文件的內容非常多的話肯定是不行的,可能就會導致瀏覽器掛掉,客戶機器死機的問題
    現整理了個解決辦法,代碼如下:

    1.下載頁面
    open(action執行頁面,'iframeName','');
    2.action執行頁面
    <id="tempB" style="display:none" href="#" onclick="">&nbsp;</a>
    <iframe width=0 height=0 id="hideIframe" name="hideIframe"></iframe>
    <script>
        
    var n=0;
        
    function go(url){
            
            n
    ==0?new function()
            
    {
                frames(
    "hideIframe").location=url,n=1
            }
    :null;
            
            document.all(
    "hideIframe").readyState!="complete"?setTimeout(go,10):so();
            
            
    function so()
            
    {
                frames(
    "hideIframe").document.execCommand("SaveAs"),n=0
            }
    ;
        }

        
        
    var tempB = document.getElementById("tempB");
        
    <%
            
    if(path.toLowerCase().indexOf(".txt")>=0){
        
    %>
        tempB.attachEvent('onclick',
    function(){go('<%=request.getContextPath()+"/tempfile/1.txt">');});
        
    <%
            }
    else{
        
    %>
        tempB.attachEvent('onclick',
    function(){open('<%=request.getContextPath()+"/tempfile/1.xls">','','');});
        
    <%
            }

        
    %>
        tempB.click();
    </script>


    posted @ 2008-11-23 19:28 JGAO編程隨筆 閱讀(753) | 評論 (0)編輯 收藏

    websphere部署war應用失敗

    websphere部署war應用失敗正常原因是web.xml的節點定義循序問題,或者一些空格,字符原因造成的
    可能先定義完所有的servlet后再定義所有的servlet mapping就沒問題了

    posted @ 2008-08-23 15:27 JGAO編程隨筆 閱讀(636) | 評論 (0)編輯 收藏

    通過jsf事件轉向后的頁面中文亂碼

    那個轉向后的頁面已經有用gb2312的編碼了
    可能原因是在java類里面調用了((HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse()).getWriter().write("");
    然后再轉向某個頁面,這樣可能導致編碼格式沖突,導致亂碼
    可以先給resonse設置下編碼格式,然后在write
    HttpServletResponse httpServletResponse = (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
    httpServletResponse.setContentType("text/html; charset=gb2312");
    httpServletResponse.setCharacterEncoding("gb2312");
    httpServletResponse.getWriter().write("");
    這樣應該就可以解決了

    posted @ 2008-06-26 23:46 JGAO編程隨筆 閱讀(588) | 評論 (0)編輯 收藏

    websphere的servlet配置無效問題

    C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\config\cells\app-bi2Node01Cell\applications\appname.ear\deployments\appname\appname.war\WEB-INF\web.xml 該目錄下的web.xml的修改才是有效

    應用程序發布的目錄下的那個web.xml添加的servlet配置是無效的

    posted @ 2008-04-28 18:06 JGAO編程隨筆 閱讀(1474) | 評論 (3)編輯 收藏

    jsp的request.getParameter獲取不到表單參數

    可能原因:

    1: form表單中的控件沒有定義name屬性

    2: form表單中的控件被設置成disabled

    3: form表單的enctype="multipart/form-data"是一種用于上傳文件的表單

    解決方法:

    對于第三種情況我們直接request.getParameter來取參數值是取不到的

    我們可以借用apache的上傳組件來解決

    用到jarcommons-fileupload-1.1.1.jar

    import org.apache.commons.fileupload.FileItem;

    import org.apache.commons.fileupload.FileItemFactory;

    import org.apache.commons.fileupload.FileUploadException;

    import org.apache.commons.fileupload.disk.DiskFileItemFactory;

    import org.apache.commons.fileupload.servlet.ServletFileUpload;

        /**

         *獲取各種類型表單的表單參數

         *@paramrequest HttpServletRequest請求對像

         * @paramparamName 參數名

         *@return

         *@throwsFileUploadException

         */

        publicstatic String getParameterValue(HttpServletRequest request,String paramName) throws FileUploadException{

        boolean isMultipart = ServletFileUpload.isMultipartContent(request);

        if(isMultipart==true){

            FileItemFactory factory = new DiskFileItemFactory();

            ServletFileUpload upload = new ServletFileUpload(factory);

            List fileItemList = upload.parseRequest(request);

            if(fileItemList!=null){

               for(Iterator itr=fileItemList.iterator();itr.hasNext();){

                   FileItem fileItem = (FileItem)itr.next();

                   if(fileItem.getFieldName().equalsIgnoreCase(paramName)){

                       return new String(fileItem.getString().getBytes("ISO8859-1"))//中文轉碼

                   }

               }

            }

        }else{

            return new String(request.getParameter(paramName).getBytes("ISO8859-1"))//中文轉碼

        }

        return"";

        }

    posted @ 2007-12-14 19:07 JGAO編程隨筆 閱讀(14900) | 評論 (6)編輯 收藏

    初學jsf自定義標簽時遇到的問題總結

    1.定義一個標簽要用到兩個java類,這個跟jsp的自定義標簽有點不一樣
      第一個類繼承UIComponentTag, 用于定義標簽的屬性和設置標簽的所有屬性值到控件的map屬性attributes或valueBinding中
      第二個類繼承UIInput或者UIOutput,用于渲染標簽的內容,真正打印標簽內容的地方就在這里
       
    2.這兩個類是怎么聯系的
     我們需要像定義jsf的bean的影射文件一樣,在faces-config.xml或者自己定義的xml文件里面定義第二個類
     如:
     
    <faces-config>
      
    <!--分頁標簽-->
      
    <component>
        
    <component-type>pageTag</component-type>
        
    <component-class>com.jsf.PageComponent</component-class>
      
    </component>
      
      
    </faces-config>
      然后第一個類要實現父類的一個方法 public String getComponentType();從這里返回一個字符串pageTag,這樣就跟第二個類聯系起來了

    3.標簽屬性的定義
      標簽屬性的定義一般都是可轉化為字符串的類型的,除非你還是用
    <%=rowList%>這種jsp賦值的方式
      別以為你定義的一個List類型的屬性可以用jsf的EL表達式可以直接賦值進來,EL表達式傳進來以后屬性接收的就是這一串EL表達式
      所以就是說你的屬性就是要字符串類型的

    4.那么jsf自定義標簽是怎么接收EL表達式綁定的列表的
     先通過父類的isValueReference(屬性值),來判斷該屬性的值是否是一個EL的表達式
     如果是則通過獲取綁定值得方式把真正的屬性的值設置到標簽父類的valueBinding對像中
     否則直接把屬性的值添加到標簽父類的attributes對像中
      if (isValueReference(屬性值)) {
        javax.faces.el.ValueBinding vb = Util.getValueBinding(value.toString());
        component.setValueBinding(name, vb); //component就是標簽對像,name就是標簽的屬性名稱
     } else {
        component.getAttributes().put(name, 屬性值);
     }

     這就是個設置屬性值的過程,可以在第1點說的第一個類里面的protected void setProperties(UIComponent component)方法
    5.現在知道標簽屬性值的作用了嗎
     是的標簽屬性值只不過是起個作用而已,而不是我們真正所要的值
     也就是說我們是不能從這些屬性中直接取值的
     
    6.那么我們怎么取屬性的真正的值呢
     可以先從第4點說的標簽父類的attributes對像中取值
     如果取不到值那就到標簽父類的valueBinding對像中取值
     說白了就是,通過第4步我們屬性的真正的值不是放在attributes就是在valueBinding中
     Object obj = component.getAttributes().get(name); //component就是標簽對像,name就是標簽的屬性名稱
     if (obj == null) {
       ValueBinding vb = component.getValueBinding(name);
       if (vb != null) {
        return vb.getValue(context);
       } else {
        return null;
       }
     }
     這個過程就是取屬性值的過程,在第1點說的第二個類里面進行
     
    7.現在屬性值也可以取到了,那么我們要怎么打印標簽的內容呢
      我們可以在第二個類的encodeBegin或者encodeEnd中進行
      public void encodeBegin(FacesContext context) throws IOException
      public void encodeEnd(FacesContext context) throws IOException
     
      取屬性值的過程也可以在這里進行,取完值后就是把值組裝到標簽內容的相應位置中就完了
      
      基本上就是這幾點

    posted @ 2007-11-21 19:21 JGAO編程隨筆 閱讀(2146) | 評論 (4)編輯 收藏

    ajax4jsf跟outputStream.write沖突?

    我在項目中引入ajax4jsf框架
    web.xml中加入

     <filter>
            
    <display-name>Ajax4jsf Filter</display-name>
            
    <filter-name>ajax4jsf</filter-name>
            
    <filter-class>org.ajax4jsf.Filter</filter-class>
      
    </filter>
      
    <filter-mapping> 
          
    <filter-name>ajax4jsf</filter-name>
          
    <servlet-name>Faces Servlet</servlet-name>
          
    <dispatcher>REQUEST</dispatcher>
          
    <dispatcher>FORWARD</dispatcher>
          
    <dispatcher>INCLUDE</dispatcher>
     
    </filter-mapping>


    結果以前的輸出文件到客戶端的代碼就出問題了

                    InputStream fileInputStream = mgt.downloadToStream(result_pathEl.getTextTrim());
                    mgt.deleteFile(result_pathEl.getTextTrim());
    //刪除臨時的報表文件
                    JSFUtil.setSessionAttribute(sessionId, "true");
                    
    if( fileInputStream == null ){
                      System.out.println(
    "==========get inputstream is null========");
                    }


                    OutputStream o 
    = response.getOutputStream();
                    response.reset();
                    response.setContentType( 
    "APPLICATION/OCTET-STREAM" );
                    response.setHeader( 
    "Content-Disposition""attachment;filename=\"" + "exportExcel.xls""\"" );

                    
    int length;
                    
    byte buf[] = new byte[1024];

                    
    while ( ( length = fileInputStream.read( buf, 01024 ) ) != -1 ) {
                        o.write( buf, 
    0, length );
                    }

                    o.flush();
                    o.close();
                    fileInputStream.close();


    提示錯誤如下:主要是o.write出問題

    java.lang.NullPointerException
            at org.ajax4jsf.framework.ajax.xmlfilter.FilterServletResponseWrapper$By
    teArrayServletOutputStream.write(FilterServletResponseWrapper.java:290)


    把web.xml中的ajax4jsf的filter給去掉后,一切又恢復正常

    有那位仁兄遇到同樣情況的嗎?

    posted @ 2007-11-19 20:16 JGAO編程隨筆 閱讀(448) | 評論 (1)編輯 收藏

    取程序的絕對路徑問題

    在本地tomcat5中這樣沒問題
    request.getRealPath("/")+"report/config/configFile/"+priv_id+".xml"

    但是發布到websphere6后就出問題了
    要改成
    request.getRealPath("/")+"/report/config/configFile/"+priv_id+".xml"

    就是report前要加個"/" 斜杠,加了后tomcat5下也是正確的

    posted @ 2007-11-09 18:25 JGAO編程隨筆 閱讀(249) | 評論 (0)編輯 收藏

    程序從oracle移植到db2遇到的問題

     

    1.jdk環境問題

    jdk環境要改為ibm jdk 5.0, 不然連接不上數據庫, 數據庫連接池的連接失敗,c3p0連接池的連接失敗,目前還是默認的方式采用應用服務器的連接池,像tomcat就采用tomcat配置的連接池

    eclipse 的開發時用的jre如果修改為ibm的以后,有可能會導致編譯不了,這要修改編輯器java類型的編碼為gb2312就可以了,genaral->content type –java file

    2. 程序中編寫sql時的用戶模式問題

    用戶模式要用公共常量,以便修改

    不同用戶模式之間的表的訪問通過授權來解決

    3. db2數據庫的函數問題

    程序中的添加和修改時間的地方的日期函數都要修改成

    Date(“2007-01-01”)就是字符串中間有帶中杠的

    日期轉字符串要把原先的to_char改成char(int(2007-01-01))

    Kpi的消息串在配置中在取權限priv_id的字符串要加上char(int(priv_id)),如果直接char(priv_id)會多出一個點號

    4. oracle樹形結構的查詢移植到db2存在問題

    菜單查詢中,有存在層次level的沒實現,目前我先通過自己寫的函數實現,但存在問題跟沒有層次的實現方式一樣存在問題

    因為通過in的方式,in的存在字段是有限的到時候數據量變多了,sql就會執行失敗,可以考慮臨時表來解決

    5. 序列表seq的長度問題

    所有的序列表的序列長度db2是有限制的,好像不能大于8位,這樣序列的字段都要做修改,而且不能重復,要進一步確認修改

    7. 系統權限移植問題

    地區編碼的字段從數值型改為字符串類型,很辛苦,建議以后程序的bean的屬性都用字符串來定義,避免程序移植的類型修改的問題

    8. erwin數據模型問題

    數據模型中的部分表沒有及時更新,跟開發時用的表有出入,以后數據模型要及時更新

    9. 建表的sql語句問題

           建表的sql

     number(12) 這樣的都要改成decimal(12,0)

     varchar2都要改成varchar

    posted @ 2007-10-27 23:27 JGAO編程隨筆 閱讀(391) | 評論 (0)編輯 收藏

    用ibm的東西

    用ibm的東西前先裝ibm的jdk

    posted @ 2007-10-20 15:33 JGAO編程隨筆 閱讀(172) | 評論 (0)編輯 收藏

    表單提交后獲取不到控件的值

    有時候我們在表單提交后卻獲取不到控件的值
    可能原因:
    1. 控件少了name屬性
    2.控件被設置成disabled

    posted @ 2007-07-06 23:38 JGAO編程隨筆 閱讀(357) | 評論 (0)編輯 收藏

    OutputStream 轉 InputStream

    使用場合: 操作excel或pdf等文件時需要先寫到輸出流, 然后又要用到ftp上傳該excel或pdf文件需要用到輸入流作為參數,這時候我們就可以直接把該文件的輸出流轉為輸入流直接上傳到ftp服務器上

      1.
      ByteArrayOutputStream os 
    = new ByteArrayOutputStream();
      InputStream is 
    = new ByteArrayInputStream(os.toByteArray());

    posted @ 2007-06-18 22:41 JGAO編程隨筆 閱讀(4416) | 評論 (0)編輯 收藏

    設置file控件的按鈕樣式

    網上找的,分享一下
    <html>
    <script>
    function fclick(obj){
    with(obj){
    style.posTop
    =event.y-offsetHeight/2
    style.posLeft
    =event.x-offsetWidth/2
    }

    }

    </script>
    <style>
    input
    {border:1px solid #333333;color:#666666;background:#eeeeee;font:normal 12px Tahoma;height:18px}
    </style>
    <br>
    <br>
    <br>
    <table>
    <tr>
    <td>
    <form method="post" action="" enctype="multipart/form-data">
    <input id="f_file">&nbsp;<input type="button" onmouseover="fclick(t_file)" value="選擇上傳文件">
    <br>
    <input name="upload" type="file" style="position:absolute;filter:alpha(opacity=10);width:30px;" id="t_file" onchange="f_file.value=this.value" hidefocus>
    <br><input type="submit" value="提交">
    </form>
    </tr>
    </table>
    </html>

    posted @ 2007-06-14 23:03 JGAO編程隨筆 閱讀(2486) | 評論 (3)編輯 收藏

    進度條思想

    后臺數據處理完成的時候設置一個處理完成的session標志
    前臺通過發送ajax請求設置成功標志的session的頁面,如果session的成功標志為true則數據處理完成,關閉正在處理的進度條圖片,否則繼續發送ajax請求,顯示正在處理的進度條圖片,當然也可以通過后臺返回數據處理完成的百分比,來制作精確的進度條

    posted @ 2007-06-14 23:00 JGAO編程隨筆 閱讀(212) | 評論 (0)編輯 收藏

    動態設置checkbox的checked屬性

    當我們在做動態生成checkbox和動態設置checkbox的checked屬性的時候要注意
    只有checkbox在頁面生成以后設置checkbox的checked屬性才有效,否則是無效的
    也就是說不要在create checkbox后就設置checked屬性,要等到該checkbox已經append到頁面中了在來設置checked屬性這樣才可以

    posted @ 2007-05-22 23:44 JGAO編程隨筆 閱讀(1532) | 評論 (1)編輯 收藏

    response.sendredirect的問題

    1) 使用response.sendredirect重定向是沒辦法通過request.setAttribute來傳遞對象到另外一個頁面的
    但我們可以通過轉發的方式來實現request.getRequestDispatcher("test2.jsp").forward(request,response)
    這也是struts默認的頁面跳轉方式,這就是為什么我們可以在action里面request.setAttribute然后在頁面里request.getAttribute

    2) 使用response.sendredirect重定向要記得在后面加上return不然后面的語句還是會繼續往下執行的,還有就是response.sendredirect之前最好不要有任何的輸出語句包括html不然可能會重定向失敗
    最近我還遇到一個比較奇怪的問題就是response.sendredirect失敗,因為我的端口是通過交換機來轉換的所以可能就是在這里重定向不過去了,所以建議以后大家都使用request.getRequestDispatcher("test2.jsp").forward(request,response)這種方式就不會錯了,當然也可以用jsp標簽的forward

    posted @ 2007-05-07 21:47 JGAO編程隨筆 閱讀(1077) | 評論 (0)編輯 收藏

    可定制生命周期的緩存

         摘要: 1) ICache.java 緩存接口 package com.jgao.cache;/** *//** * 緩存接口 * @author jgao * */public interface ICache {      ...  閱讀全文

    posted @ 2007-04-22 06:18 JGAO編程隨筆 閱讀(1007) | 評論 (0)編輯 收藏

    獲取第N級的所有節點實現代碼

    ??? 基本的思想和步驟都在了,主要就是遞歸

    ??? /**
    ???? * 傳入級數返回存放該級數下所有組織列表的列表
    ???? * @param lever int 組織級數
    ???? * @return List<List> 存放組織列表
    ???? */

    ??? public List<List> getTreeLeverNode(int lever) {
    ??????? String sqlstr = "select? ID from?table1 where PARENT_ID=0";
    ??????? Result ret = Dao.executeQuery(sqlstr);
    ??????? List<List> list = new Vector<List>();
    ??????? List rslist = new Vector();
    ??????? List<String> nodeList = new Vector<String>();
    ??????? for (int i = 0; i < ret.Length(); i++) {
    ??????????? rslist = getNextNode(Integer.parseInt(ret[i]
    ??????????????????????? .toString()), lever - 1, nodeList);
    ??????????????? list.add(rslist);
    ??????? }
    ??????? return list;
    ??? }

    ??? /**
    ???? * 返回存放該級數下所有組織的列表
    ???? * @param reqParentid 請求傳入的父節點ID
    ???? * @param lever 組織級數
    ???? * @param list 存放該級數下所有組織的列表
    ???? * @return List<String> 存放組織
    ???? */

    ??? public List<String> getNextNode(int reqParentid, int lever, List list) {
    ??????? String sqlstr = "select? ID from?table1 where PARENT_ID="
    ??????????????? + reqParentid;
    ??????? DBResult ret = super.executeQuery(sqlstr);
    ??????? List rslist = new Vector();
    ??????? lever = lever - 1;
    ??????? if (lever > 0) {
    ???????????for (int i = 0; i < ret.Length(); i++) {
    ?????????????????rslist = getNextNode(Integer.parseInt(ret[i]
    ??????????????????????? .toString()), lever , nodeList);
    ??????????????? list.add(rslist);
    ???????????}
    ??????? } else {
    ??????????? for (int i = 0; i < ret.Length(); ; i++) {
    ????????????????list.add(ret[i].toString());
    ??????????? }
    ??????? }
    ??????? return list;
    ??? }

    posted @ 2007-01-15 20:30 JGAO編程隨筆 閱讀(122) | 評論 (0)編輯 收藏

    erwin連接oracle9i數據庫

    剛使用erwin時在連接oracle9i數據庫時的那個連接串我一直用jdbc連接oracle的那個格式,所以一直連都連不上
    一直出現“內部錯誤,hostdef擴展名不存在”,很是郁悶,不知大家有沒遇到
    后來查了一下,才知道本地的話要進行本地的Net服務名配置
    配置工具在開始->oracle->Configuration and Migration Tools->NET CONFIGUATION ASSISTANT
    然后選擇本地的Net服務名配置,在配置到服務名的時候把你的數據庫名稱添進去,然后往下到完成就行了

    也可以直接編輯tnsnames.ora,如下圖:

    接下來在erwin進行正向或者反向工程的操作界面,提示連接數據庫的那個連接字符串里輸入你的那個服務名就行了,當然用戶名密碼還是要跟之前的一樣,如下圖:

    posted @ 2007-01-14 17:23 JGAO編程隨筆 閱讀(3383) | 評論 (15)編輯 收藏

    獲取第N級的所有節點

    /**
    *臨時寫的偽代碼
    */

    //獲取第N級的所有節點

    public list getTreeLeverNode(int lever)
    ??rs0 = select id from menu where parentid is null;? //先從數據庫取出第一級的所有節點
    ??if(lever<=1)
    ? return rs0
    ? //循環第一級的節點遞歸取下面的節點
    ??for(int i=0; i<rs0.length; i++){
    ???rslist = getNextNode(rs0[i],lever-1);
    ???list.add(rslist);
    ??}
    ??return rs1;
    }

    public list getNextNode(int reqParentid,int lever){
    ??rs2 = select id from menu where parentid = reqParentid;
    ??lever = lever -1;
    ??if(lever>0){
    ???for(int i=0; i<rs2.length; i++){
    ????rs2 = getNextNode(rs2[i],lever);
    ????list.add(rs2);
    ???}
    ??}
    ??return rs2;
    }

    posted @ 2007-01-14 16:01 JGAO編程隨筆 閱讀(160) | 評論 (0)編輯 收藏

    數據操作控制

    ??????1.當執行一個功能的時候需要執行多個更新操作,如:插入多個對象,刪除多個對象等,就可能存在執行一個更新操作成功之后下一個更新操作失敗,那么這個功能的執行就算是失敗的,可是卻向數據庫添加或刪除了不完全的相關數據,所以就會出現臟數據
    ??????解決方法:
    ??????1) 通過事物控制讓多個執行語句一起提交commit,commit失敗的話就回滾rollback,做到事物的原子性原則
    ??????2) 在數據庫設置一個操作成功或失敗的字段(或者本地臨時文件里存放相關的控制數據),通過該字段進行控制,在執行出錯后刪除所有含有操作失敗字段的數據
    ???????
    ??????2.數據庫同步訪問控制:比如說一條記錄有兩個以上的用戶同時訪問,他們讀取出來的是相同的數據,但寫入時有先后,如果不做控制就會出現后來寫入的數據把原來做了更新的數據覆蓋,使原來做的更新操作丟失就是無效,因為他們都是在最原始讀取出來的數據上做的修改,而不是在別人做了修改后的數據上做修改
    ??????解決方法:
    ??????1) 可以在數據庫多設置一個版本字段來控制該數據的歷史版本號(或者本地臨時文件里存放相關的控制數據),就是沒個人做了修改以后都要更新一下這個版本字段,同時更新之前也要做一下版本的比較,如果現在的版本和之前取出來的數據的版本不一樣,那么就要從新讀取數據再寫入,這樣就可以保證不會丟失修改
    ?????

    posted @ 2007-01-14 12:00 JGAO編程隨筆 閱讀(176) | 評論 (0)編輯 收藏

    tomcat下jsf移到weblogic8下出錯

    錯誤如下:Servlet: "Faces" failed to preload on startup in Web application
    我的方法是修改web.xml如下:
    <?xml version="1.0" encoding="gb2312"?>
    <web-app xmlns="
    http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee?? http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    ?<context-param>
    ??<param-name>javax.faces.CONFIG_FILES</param-name>
    ??<param-value>/WEB-INF/faces-config.xml</param-value>
    ?</context-param>
    ?
    ? //listener節點是新加的
    ?<listener>
    ??<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    ?</listener>
    ?
    ?<servlet>
    ??<servlet-name>Faces Servlet</servlet-name>
    ??<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    ??<load-on-startup>-1</load-on-startup>//本來是0先在改為-1
    ?</servlet>
    ?
    ?<servlet-mapping>
    ??<servlet-name>Faces Servlet</servlet-name>
    ??<url-pattern>*.faces</url-pattern>
    ?</servlet-mapping>
    </web-app>

    posted @ 2006-12-07 17:45 JGAO編程隨筆 閱讀(838) | 評論 (3)編輯 收藏

    tomcat 同時開多個端口

    tomcat要同時開多個端口只要配置conf文件夾下面的server.xml增加Service節點就可以了,如下我多開了個8083端口,同時我把Catalina文件夾多拷貝了一份另存為Catalina2
    <Server port="8005" shutdown="SHUTDOWN" debug="0">


    ? <!-- Comment out these entries to disable JMX MBeans support -->
    ? <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
    ??????????? debug="0"/>
    ? <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
    ??????????? debug="0"/>

    ? <!-- Global JNDI resources -->
    ? <GlobalNamingResources>

    ??? <!-- Test entry for demonstration purposes -->
    ??? <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

    ??? <!-- Editable user database that can also be used by
    ???????? UserDatabaseRealm to authenticate users -->
    ??? <Resource name="UserDatabase" auth="Container"
    ????????????? type="org.apache.catalina.UserDatabase"
    ?????? description="User database that can be updated and saved">
    ??? </Resource>
    ??? <ResourceParams name="UserDatabase">
    ????? <parameter>
    ??????? <name>factory</name>
    ??????? <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
    ????? </parameter>
    ????? <parameter>
    ??????? <name>pathname</name>
    ??????? <value>conf/tomcat-users.xml</value>
    ????? </parameter>
    ??? </ResourceParams>

    ? </GlobalNamingResources>

    ? <!-- Define the Tomcat Stand-Alone Service -->
    ? <Service name="Catalina">

    ??? <!-- Define a non-SSL Coyote HTTP/1.1 Connector on the port specified
    ???????? during installation -->
    ??? <Connector
    port="8081"?????????????? maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    ?????????????? enableLookups="false" redirectPort="8443" acceptCount="100"
    ?????????????? debug="0" connectionTimeout="20000"
    ?????????????? disableUploadTimeout="true" />

    ??? <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
    ??? <Connector port="8009"
    ?????????????? enableLookups="false" redirectPort="8443" debug="0"
    ?????????????? protocol="AJP/1.3" />
    ????????
    ??? <!-- Define the top level container in our container hierarchy -->
    ??? <Engine name="Catalina" defaultHost="localhost" debug="0">
    ????? <!--
    ????? <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
    ????? -->

    ????? <!-- Global logger unless overridden at lower levels -->
    ????? <Logger className="org.apache.catalina.logger.FileLogger"
    ????????????? prefix="catalina_log." suffix=".txt"
    ????????????? timestamp="true"/>


    ????? <!-- This Realm uses the UserDatabase configured in the global JNDI
    ?????????? resources under the key "UserDatabase".? Any edits
    ?????????? that are performed against this UserDatabase are immediately
    ?????????? available for use by the Realm.? -->
    ????? <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
    ???????????????? debug="0" resourceName="UserDatabase"/>

    ????? <!-- Define the default virtual host -->
    ????? <Host name="localhost" debug="0" appBase="webapps"
    ?????? unpackWARs="true" autoDeploy="true">


    ??????? <Logger className="org.apache.catalina.logger.FileLogger"
    ???????????????? directory="logs"? prefix="localhost_log." suffix=".txt"
    ??????????? timestamp="true"/>

    ??????? <!--
    ????????? <Context path="" docBase="ROOT" debug="0">
    ??????? -->
    ????? </Host>

    ??? </Engine>

    ? </Service>
    ?
    ??? <Service name="Catalina2">

    ??? <Connector
    port="8083"?????????????? maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    ?????????????? enableLookups="false" redirectPort="8443" acceptCount="100"
    ?????????????? debug="0" connectionTimeout="20000"
    ?????????????? disableUploadTimeout="true" />


    ??? <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
    ??? <Connector port="8010"
    ?????????????? enableLookups="false" redirectPort="8443" debug="0"
    ?????????????? protocol="AJP/1.3" />

    ????????
    ??? <!-- Define the top level container in our container hierarchy -->
    ??? <Engine name="Catalina2" defaultHost="localhost" debug="0">


    ????? <!-- Global logger unless overridden at lower levels -->
    ????? <Logger className="org.apache.catalina.logger.FileLogger"
    ????????????? prefix="catalina_log." suffix=".txt"
    ????????????? timestamp="true"/>

    ????? <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
    ???????????????? debug="0" resourceName="UserDatabase"/>


    ????? <Host name="localhost" debug="0" appBase="webapps"
    ?????? unpackWARs="true" autoDeploy="true">


    ??????? <Logger className="org.apache.catalina.logger.FileLogger"
    ???????????????? directory="logs"? prefix="localhost_log." suffix=".txt"
    ??????????? timestamp="true"/>

    ????? </Host>

    ??? </Engine>

    ? </Service>

    </Server>

    posted @ 2006-12-07 14:23 JGAO編程隨筆 閱讀(2556) | 評論 (0)編輯 收藏

    eclipse 配置weblogic服務器

    我剛配置時出現的錯誤及解決方法:
    1.啟動時出現如下錯誤
    The WebLogic Server did not start up properly.
    java.io.InvalidClassException: javax.management.MBeanAttributeInfo; local class incompatible: stream classdesc serialVersionUID = 7043855487133450673, local class serialVersionUID = 8644704819898565848
    ?at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:519)
    ?at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1546)
    ?at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
    ?at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1546)
    ?at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
    ?at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693)
    ?at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
    ?at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1628)
    ?at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1293)
    ?at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
    ?at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)<2006-12-6 下午05時39分36秒 CST> <Info> <Configuration Management> <BEA-150016> <This server is being started as the administration server.>
    <2006-12-6 下午05時39分36秒 CST> <Info> <Management> <BEA-141107> <Version: WebLogic Server 8.1 SP2? Fri Dec 5 15:01:51 PST 2003 316284
    WebLogic XMLX Module 8.1 SP2? Fri Dec 5 15:01:51 PST 2003 316284 >

    原因是配置weblogic時用了jdk1.5改成weblogic自帶的jdk1.4就可以解決了

    2.啟動時出現如下錯誤
    ***************************************************************************
    The WebLogic Server did not start up properly.
    Exception raised: 'weblogic.management.configuration.ConfigurationException: Unable to locate server named myServer in the configuration file config.xml. Please ensure the argument -Dweblogic.Name=<serverName> matches a server name in that file, for example: <Server ... Name="someName"/>.A single server was found namedmyserver'
    Reason: weblogic.management.configuration.ConfigurationException: Unable to locate server named myServer in the configuration file config.xml. Please ensure the argument -Dweblogic.Name=<serverName> matches a server name in that file, for example: <Server ... Name="someName"/>.A single server was found namedmyserver
    ***************************************************************************
    原因是配置weblogic信息時的內容跟你的F:\bea\user_projects\domains\mydomain\
    config.xml文件里的內容不一致包括大小寫,改過來就行了
    主要是domain name和server name 如下是mydomain
    myserver
    <Domain ConfigurationVersion="8.1.2.0" Name="mydomain">
    ??? <Server ListenAddress="localhost" ListenPort="7001" Name="myserver"

    posted @ 2006-12-06 17:47 JGAO編程隨筆 閱讀(1258) | 評論 (0)編輯 收藏

    jdbc 連接sqlserver的問題

    很多人剛開始在用jdbc連接sqlserver時都出現問題,也就是連接不上
    大部分的什么配置工作啊,驅動程序啊,程序的連接語句啊這些相信都沒錯,因為網上隨便都能找到,而且說得也很清楚了
    最主要的一個原因可能就是sp3補丁沒打,打完后或許就能連接上了

    posted @ 2006-11-08 21:43 JGAO編程隨筆 閱讀(192) | 評論 (0)編輯 收藏

    bgcolor 郁悶了我一整天

    ?var row=document.createElement('tr');
    ?row.setAttribute('bgcolor','#00CCFF');


    這樣設置了半天就是沒效果,找了半天就是找不出原因

    后來我直接在頁面上寫<tr bgcolor="#00CCFF"></tr>
    然后在程序里innerHTML
    發現兩個bgcolor打印出來是不一樣的

    我程序里的是原樣的bgcolor而靜態寫好的bgcolor卻變成bgColor看到沒c變成了大寫了,然后我也跟著改成?row.setAttribute('bgColor','#00CCFF');
    神了真的就可以了,哎無語啊!

    posted @ 2006-09-21 11:07 JGAO編程隨筆 閱讀(249) | 評論 (0)編輯 收藏

    ajax+strutsAction 小例子

    本程序對ajax的一些基礎調用進行了封裝,使用者只要實現具體的事件驅動程序就可以
    了,如本例子的doTest.js, 然后把該文件引進相對應的jsp文件里面,如test.jsp


    test.jsp


    <%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
    <script src="ajaxjs/ajaxInit.js" type="text/javascript"></script>
    <script src="ajaxjs/doTest.js" type="text/javascript"></script>
    <html>
    ? <body>
    ? <input name="testText" type="text" value="">
    ? <input type="button" value="test" onclick="doTestRequest(document.getElementById('testText').value,'jgaopass','doTestAfterRequest','responseText');">
    ? </body>
    </html>


    doTest.js


    //測試函數
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /**
    * 請求
    * doAfterRequestMethodName 請求成功后的要執行的函數名稱
    * responseTypeName ajax異步調用后返回的內容的類型,可以使responseText或者responseXml
    */

    function doTestRequest(userName, userPwd, doAfterRequestMethodName, responseTypeName){?
    ?var param = setQueryString('userName',userName,'userPwd',userPwd);
    ?sendRequest('toStrutsAjaxTest.do',param,doAfterRequestMethodName,responseTypeName);
    }

    //請求成功后的執行內容
    function doTestAfterRequest(responseString){
    ?var teststring = document.getElementById("testText");
    ?teststring.value = responseString;
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


    ajaxInit.js

    //全局變量
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    var xmlHttp = false;
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////??

    //公共函數
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //創建XMLHttpRequest對象

    function createXMLHttpRequest() {???
    ?if (window.XMLHttpRequest) {//Mozilla 等瀏覽器??? ?
    ??xmlHttp = new XMLHttpRequest();
    ??? ?} else {?? ??
    ??? ??if (window.ActiveXObject) {// IE瀏覽器
    ??? ???try {
    ??? ????xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    ??? ???}
    ??? ???catch (e) {
    ??? ????try {
    ??? ???? ?xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    ??? ????}
    ??????????????? ??catch (e) {
    ??????????????? ??}
    ????????? ??}
    ????? ??}
    ?}
    ? ?if (xmlHttp.overrideMimeType) {//修改MiME類型
    ? ??xmlHttp.overrideMimeType("text/xml");
    ? ?}??
    ? ?if (!xmlHttp) {//創建XMLHttpRequest失敗
    ? ??window.alert("創建XMLHttpRequest失敗");
    ?? ??return false;
    ? ?}
    }

    //向后臺發送請求的參數設置
    function setQueryString(){
    ?var param="";
    ??for(var i=0;i<arguments.length;i++){
    ??param+=arguments[i]+'='+encodeURI(arguments[i+1]);
    ??if(i!=arguments.length-2){
    ???param+="&";
    ???i++;
    ??}else{
    ???break;
    ??}?
    ?}
    ?return param;
    }

    /**
    * 發送請求
    * doAfterRequestMethodName 請求成功后的要執行的函數名稱
    * responseTypeName ajax異步調用后返回的內容的類型,可以使responseText或者responseXml
    */

    function sendRequest(requestUrl,param,doAfterRequestMethodName,responseTypeName){
    ?createXMLHttpRequest();?
    ?xmlHttp.open('POST',requestUrl,true);
    ?xmlHttp.setrequestheader("content-type","application/x-www-form-urlencoded");
    ?xmlHttp.onreadystatechange= function(){regCallBack(doAfterRequestMethodName,responseTypeName);};
    ?xmlHttp.send(param);
    }

    //回調函數
    function regCallBack(doAfterRequestMethodName,responseTypeName){?
    ?if(xmlHttp.readyState == 4){
    ??if(xmlHttp.status == 200){
    ????? ???doAfterRequest(doAfterRequestMethodName,responseTypeName);
    ??}
    ?}
    }

    //請求成功后的執行函數
    function doAfterRequest(doAfterRequestMethodName,responseTypeName){
    ?var responseString = "";
    ?if (responseTypeName!=null){
    ??if (responseTypeName == "responseText"){
    ???responseString = xmlHttp.responseText;
    ??}
    ??if (responseTypeName == "responseXml"){
    ???responseString = xmlHttp.responseXml;
    ??}
    ?}?
    ?if(doAfterRequestMethodName!=null){
    ??eval(doAfterRequestMethodName+"('"+responseString+"')");
    ?}
    }
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    struts-config.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "
    http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd ">

    <struts-config>
    ? <data-sources />
    ? <form-beans />
    ? <global-exceptions />
    ? <global-forwards />
    ? <action-mappings >
    ??? <action path="/toStrutsAjaxTest" type="com.jgao.ajax.test.struts.action.ToStrutsAjaxTestAction">
    ?</action>
    ? </action-mappings>
    ? <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
    </struts-config>


    ToStrutsAjaxTestAction.java

    //Created by MyEclipse Struts
    // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.0/xslt/JavaClass.xsl

    package com.jgao.ajax.test.struts.action;

    import java.io.IOException;
    import java.io.PrintWriter;

    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;

    /**
    ?* MyEclipse Struts
    ?* Creation date: 09-18-2006
    ?*
    ?* XDoclet definition:
    ?* @struts.action validate="true"
    ?*/
    public class ToStrutsAjaxTestAction extends Action {

    ?// --------------------------------------------------------- Instance Variables

    ?// --------------------------------------------------------- Methods

    ?/**
    ? * Method execute
    ? * @param mapping
    ? * @param form
    ? * @param request
    ? * @param response
    ? * @return ActionForward
    ? * @throws IOException
    ? */
    ?public ActionForward execute(
    ??ActionMapping mapping,
    ??ActionForm form,
    ??HttpServletRequest request,
    ??HttpServletResponse response) throws IOException {
    ??String teststring = request.getParameter("userName");
    ??teststring = teststring + "ok";
    ?? response.getWriter().write(teststring);
    ??return null;
    ?}

    }

    posted @ 2006-09-19 10:11 JGAO編程隨筆 閱讀(1002) | 評論 (1)編輯 收藏

    java開發出錯筆記.doc

         摘要: java 開發出錯筆記 ---powered by jgao 1. ...  閱讀全文

    posted @ 2006-06-11 08:52 JGAO編程隨筆 閱讀(1382) | 評論 (0)編輯 收藏

    jfreechart 學習筆記

    1.java 2D主要繪圖類描述(jdk1.5)
    ?Graphics2D //主要繪圖對象,每種圖形都要通過該對象來繪制
    ?Rectangle2D //長方形對象
    ?Point2D //點對象
    ?Line2D //線對象
    ?Arc2D.Double //弧形對象
    ?Ellipse2D //橢圓對象
    ?Polygon //多邊形對象
    ?Paint //油漆桶對象,用來定義顏色
    ?Stroke //畫筆對象,主要用于描繪輪廓,定義線條樣式
    ?Area //幾何建模對象(含幾何并交差運算等方法)
    ?GeneralPath //路徑對象
    ?
    ?1.1 sample demo eg:
    ??/**
    ?? * 利用路徑對象繪制平面圖
    ?? */
    ??// GeneralPath bar3dRight = new GeneralPath();
    ??// bar3dRight.moveTo((float) 100.0, (float) 100.0);
    ??// bar3dRight.lineTo((float) 200.0, (float) 200.0);
    ??// bar3dRight.lineTo((float) 300.0, (float) 100.0);
    ??// bar3dRight.lineTo((float) 100.0, (float) 100.0);
    ??// bar3dRight.closePath();
    ??// 填充四邊形的顏色
    ??// if (itemPaint instanceof Color) {
    ??// g2.setPaint(((Color) itemPaint).darker());
    ??// }
    ??
    ??/**
    ?? * 長方形對象加路徑對象繪制3D柱狀圖
    ?? */
    ??//正視圖
    ??Rectangle2D r2d = new Rectangle2D.Double(
    ????100.0, //x
    ????100.0, //y
    ????30.0, //width
    ????200.0 //hight
    ????);
    ??//右視圖
    ??GeneralPath bar3dRight = new GeneralPath();
    ??bar3dRight.moveTo((float) 130.0, (float) 100.0);
    ??bar3dRight.lineTo((float) 150.0, (float) 90.0);
    ??bar3dRight.lineTo((float) 150.0, (float) 290.0);
    ??bar3dRight.lineTo((float) 130.0, (float) 300.0);
    ??bar3dRight.closePath();
    ??//俯視圖
    ??GeneralPath bar3dTop = new GeneralPath();
    ??bar3dTop.moveTo((float) 100.0, (float) 100.0);
    ??bar3dTop.lineTo((float) 130.0, (float) 100.0);
    ??bar3dTop.lineTo((float) 150.0, (float) 90.0);
    ??bar3dTop.lineTo((float) 120.0, (float) 90.0);
    ??bar3dTop.closePath();
    ??Paint barpaint = Color.PINK; // 實體顏色
    ??Paint outlinepaint = Color.DARK_GRAY; // 輪廓線顏色
    ??float dash1[] = { 10.0f };
    ??// 虛線條描邊
    ??// Stroke stroke = new BasicStroke(1.0f,
    ??// BasicStroke.CAP_BUTT,
    ??// BasicStroke.JOIN_MITER,
    ??// 10.0f, dash1, 0.0f);
    ??
    ??// 實線條描邊,寬度1.0f
    ??Stroke stroke = new BasicStroke(1.0f);
    ??// g2.setColor(Color.PINK);
    ??// 先設置實體顏色
    ??g2.setPaint(barpaint);
    ??g2.setStroke(stroke);
    ??g2.fill(r2d);
    ??g2.fill(bar3dRight);
    ??g2.fill(bar3dTop);
    ??// 實體填充進繪圖對象以后,在設置輪廓線顏色(其實是上面三個實體以外的所有圖形的顏色)
    ??g2.setPaint(outlinepaint);
    ??g2.draw(r2d);
    ??g2.draw(bar3dRight);
    ??g2.draw(bar3dTop);

    ??/**
    ?? * 利用橢圓對象繪制橢圓
    ?? */
    ??Ellipse2D ellipse2D = new Ellipse2D.Double(200.0, // x
    ????100.0, // y
    ????200.0, // width
    ????200.0 // hight
    ??);
    ??Paint ellipsepaint = Color.blue;
    ??g2.setPaint(ellipsepaint);
    ??g2.fill(ellipse2D);
    ??g2.draw(ellipse2D);

    ??/**
    ?? * 利用弧形對象繪制弧形
    ?? */
    ??Arc2D.Double arc = new Arc2D.Double(350.0, // x
    ????100.0, // y
    ????200.0, // width
    ????200.0, // hight
    ????0.0, // start angle
    ????90.0, // arc angle
    ????Arc2D.PIE // pie:3.1415926
    ??);
    ??Arc2D.Double arc2 = new Arc2D.Double(350.0, // x
    ????100.0, // y
    ????200.0, // width
    ????200.0, // hight
    ????-60.0, // start angle
    ????90.0, // arc angle
    ????Arc2D.PIE // pie:3.1415926
    ??);
    ??Paint arcpaint1 = Color.GREEN;
    ??Paint arcpaint2 = Color.RED;
    ??// 設置透明度
    ??g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
    ????0.3f));
    ??g2.setPaint(arcpaint1);
    ??g2.fill(arc);
    ??g2.draw(arc);
    ??g2.setPaint(arcpaint2);
    ??g2.fill(arc2);
    ??g2.draw(arc2);

    ??/**
    ?? * 圖形的幾何運算
    ?? */
    ??// Area a = new Area(arc);
    ??// Area b = new Area(arc2);
    ??// ab交差運算,去掉兩個圖形相交的部分得到的圖形
    ??// a.exclusiveOr(b);
    ??// a交b運算
    ??// a.intersect(b);
    ??// a減去b運算,即差運算
    ??// a.subtract(b);
    ??// a并b運算
    ??// a.add(b);
    ??// g2.setPaint(arcpaint2);
    ??// g2.fill(a);
    ??// g2.draw(a);
    ??
    ??/**
    ?? * 利用jfreechart的TextBox對象繪制文本框
    ?? */
    ??// 設置透明度為1,也就是不透明了
    ??g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
    ????1.0f));
    ??TextBox textBox = new TextBox("java" // 想要顯示的字符串
    ??);
    ??textBox.draw(g2, // 繪圖對象
    ????(float) 550.0, // x坐標
    ????(float) 100.0, // y坐標
    ????RectangleAnchor.CENTER // 對齊方式
    ????);
    ??Line2D.Double line = new Line2D.Double(522.0, // 線的第一個點的x坐標
    ????100.0, // 線的第一個點的y坐標
    ????500.0, // 線的第二個點的x坐標
    ????120.0 // 線的第二個點的y坐標
    ??);
    ??g2.draw(line);

    ??/**
    ?? * 寫字
    ?? */
    ??// 字體設置
    ??Font font = new Font(null, // 字體
    ????Font.ITALIC + Font.BOLD, // 樣式(這里設置了兩種樣式,黑體+斜體)
    ????10); // 大小
    ??g2.setFont(font);
    ??Paint arcpaint3 = Color.BLACK;
    ??g2.setPaint(arcpaint3);
    ??g2.drawString("delphi", // 要寫的字符串
    ????550, // x坐標
    ????150 // y坐標
    ????);
    ????
    ?? /**
    ?? * 利用多邊形對象繪制多邊形
    ?? */
    ??int []xs = new int[] { 600, 620,
    ????640, 620 };
    ??int []ys = new int[] { 100,
    ????100, 150,
    ????150};???
    ??Polygon polygon = new Polygon(
    ????xs, //多邊形x坐標點的數組
    ????ys, //多邊形y坐標點的數組
    ????4 //數組大小
    ????);
    ??g2.setPaint(java.awt.Color.lightGray);
    ??g2.fill(polygon);
    ??g2.draw(polygon);
    ??
    ??/**
    ?? * 畫網格線
    ?? */?
    ??for(double i=0.0; i<450.0; i+=30.0){
    ???// 網格線樣式
    ????? Stroke DEFAULT_GRIDLINE_STROKE = new BasicStroke(0.5f,
    ????????????? BasicStroke.CAP_BUTT,
    ????????????? BasicStroke.JOIN_BEVEL,
    ????????????? 0.0f,
    ????????????? new float[] {2.0f, 2.0f},
    ????????????? 0.0f);
    ????? Line2D.Double gridline = new Line2D.Double(0.0,i+30.0,700.0,i+30.0);
    ????? g2.setPaint(Color.GRAY);
    ????? g2.setStroke(DEFAULT_GRIDLINE_STROKE);
    ????? g2.draw(gridline);
    ??}


    2.柱狀圖2D和3D是通過CategoryPlot的renderer屬性來區別的
    ?BarRenderer //2DBarRenderer
    ?BarRenderer3D //3DBarRenderer
    ?CategoryPlot plot = new CategoryPlot(
    ??????????? dataset, categoryAxis, valueAxis, renderer
    ??????? );

    3.3D餅圖的繪制函數(現在的注釋還不夠全面,也可能存在錯誤)
    ?/**
    ? * Draws the plot on a Java 2D graphics device (such as the screen or a
    ? * printer). This method is called by the {@link org.jfree.chart.JFreeChart}
    ? * class, you don't normally need to call it yourself.
    ? *
    ? * @param g2
    ? *??????????? the graphics device.
    ? * @param plotArea
    ? *??????????? the area within which the plot should be drawn.
    ? * @param anchor
    ? *??????????? the anchor point.
    ? * @param parentState
    ? *??????????? the state from the parent plot, if there is one.
    ? * @param info
    ? *??????????? collects info about the drawing (<code>null</code>
    ? *??????????? permitted).
    ? */
    ?public void draw(Graphics2D g2, Rectangle2D plotArea, Point2D anchor,
    ???PlotState parentState, PlotRenderingInfo info) {

    ??// adjust for insets...
    ??RectangleInsets insets = getInsets();
    ??insets.trim(plotArea);

    ??Rectangle2D originalPlotArea = (Rectangle2D) plotArea.clone();
    ??if (info != null) {
    ???info.setPlotArea(plotArea);
    ???info.setDataArea(plotArea);
    ??}

    ??Shape savedClip = g2.getClip();
    ??g2.clip(plotArea);

    ??// adjust the plot area by the interior spacing value
    ??double gapPercent = getInteriorGap();
    ??double labelPercent = 0.0;
    ??if (getLabelGenerator() != null) {
    ???labelPercent = getLabelGap() + getMaximumLabelWidth()
    ?????+ getLabelLinkMargin();
    ??}

    ??// 水平方向的間隙
    ??double gapHorizontal = plotArea.getWidth()
    ????* (gapPercent + labelPercent);
    ??// 垂直方向的間隙
    ??double gapVertical = plotArea.getHeight() * gapPercent;
    ??// x坐標大小
    ??double linkX = plotArea.getX() + gapHorizontal / 2;
    ??// y坐標大小
    ??double linkY = plotArea.getY() + gapVertical / 2;
    ??// 圖形寬度
    ??double linkW = plotArea.getWidth() - gapHorizontal;
    ??// 圖形高度
    ??double linkH = plotArea.getHeight() - gapVertical;

    ??// make the link area a square if the pie chart is to be circular...
    ??if (isCircular()) { // is circular?
    ???double min = Math.min(linkW, linkH) / 2;
    ???linkX = (linkX + linkX + linkW) / 2 - min;
    ???linkY = (linkY + linkY + linkH) / 2 - min;
    ???linkW = 2 * min;
    ???linkH = 2 * min;
    ??}

    ??PiePlotState state = initialise(g2, plotArea, this, null, info);
    ??// the explode area defines the max circle/ellipse for the exploded pie
    ??// sections.
    ??// it is defined by shrinking the linkArea by the linkMargin factor.
    ??double hh = linkW * getLabelLinkMargin();
    ??double vv = linkH * getLabelLinkMargin();
    ??Rectangle2D explodeArea = new Rectangle2D.Double(linkX + hh / 2.0,
    ????linkY + vv / 2.0, linkW - hh, linkH - vv);

    ??state.setExplodedPieArea(explodeArea);

    ??// the pie area defines the circle/ellipse for regular pie sections.
    ??// it is defined by shrinking the explodeArea by the explodeMargin
    ??// factor.
    ??double maximumExplodePercent = getMaximumExplodePercent();
    ??double percent = maximumExplodePercent / (1.0 + maximumExplodePercent);

    ??double h1 = explodeArea.getWidth() * percent;
    ??double v1 = explodeArea.getHeight() * percent;
    ??Rectangle2D pieArea = new Rectangle2D.Double(explodeArea.getX() + h1
    ????/ 2.0, explodeArea.getY() + v1 / 2.0, explodeArea.getWidth()
    ????- h1, explodeArea.getHeight() - v1);

    ??// 定義3D橢圓的高度
    ??int depth = (int) (pieArea.getHeight() * this.depthFactor);
    ??// the link area defines the dog-leg point for the linking lines to
    ??// the labels
    ??Rectangle2D linkArea = new Rectangle2D.Double(linkX, linkY, linkW,
    ????linkH - depth);
    ??state.setLinkArea(linkArea);

    ??state.setPieArea(pieArea);
    ??// 定義橢圓中心點
    ??state.setPieCenterX(pieArea.getCenterX());
    ??state.setPieCenterY(pieArea.getCenterY() - depth / 2.0);
    ??// 定義橢圓寬的半徑
    ??state.setPieWRadius(pieArea.getWidth() / 2.0);
    ??// 定義橢圓高的半徑
    ??state.setPieHRadius((pieArea.getHeight() - depth) / 2.0);
    ??// 畫背景長方形(500*300)區域
    ??drawBackground(g2, plotArea);
    ??// 獲取外面傳進來3D餅圖的數據源
    ??PieDataset dataset = getDataset();??
    ??// 如果數據源為空則直接返回,整個圖表就一個背景長方形沒有數據圖形
    ??if (DatasetUtilities.isEmptyOrNull(getDataset())) {
    ???drawNoDataMessage(g2, plotArea);
    ???g2.setClip(savedClip);
    ???drawOutline(g2, plotArea);
    ???return;
    ??}

    ??/**
    ?? * 如果數據源的主鍵的個數大于圖形區域的寬度,則在圖形上顯示"Too many elements" 數據源示例如下: final
    ?? * DefaultPieDataset result = new DefaultPieDataset();
    ?? * result.setValue("Java", new Double(43.2));
    ?? * result.setValue("VisualBasic", new Double(10.0));
    ?? * result.setValue("C/C++", new Double(17.5));
    ?? * result.setValue("PHP", new Double(32.5));
    ?? * result.setValue("Perl", new Double(1.0));
    ?? * return result;
    ?? * 這個數據源的主鍵的個數為5
    ?? */
    ??if (dataset.getKeys().size() > plotArea.getWidth()) {
    ???String text = "Too many elements";
    ???Font sfont = new Font("dialog", Font.BOLD, 10);
    ???g2.setFont(sfont);
    ???FontMetrics fm = g2.getFontMetrics(sfont);
    ???int stringWidth = fm.stringWidth(text);

    ???g2
    ?????.drawString(text, (int) (plotArea.getX() + (plotArea
    ???????.getWidth() - stringWidth) / 2), (int) (plotArea
    ???????.getY() + (plotArea.getHeight() / 2)));
    ???return;
    ??}
    ??
    ??// if we are drawing a perfect circle, we need to readjust the top left
    ??// coordinates of the drawing area for the arcs to arrive at this
    ??// effect.
    ??// 如果我們畫的是一個圓形那只要知道圖形的左邊距,上邊距,和直徑
    ??if (isCircular()) {
    ???// 圓形半徑(取寬高中的小的那個數的一半)
    ???double min = Math.min(plotArea.getWidth(), plotArea.getHeight()) / 2;
    ???plotArea = new Rectangle2D.Double(
    ?????plotArea.getCenterX() - min, //左邊距(新的圖形的中心點x坐標)
    ?????plotArea.getCenterY() - min, //上邊距(新的圖形的中心點y坐標)
    ?????2 * min, //直徑(圖形的寬度)
    ?????2 * min //直徑(圖形的高度)
    ?????);
    ??}
    ??
    ??// 獲取數據源主鍵列表
    ??List sectionKeys = dataset.getKeys();
    ??// 如果數據源主鍵列表為空,退出
    ??if (sectionKeys.size() == 0) {
    ???return;
    ??}

    ??// establish the coordinates of the top left corner of the drawing area
    ??//確定pieArea區域的中心點
    ??double arcX = pieArea.getX();
    ??double arcY = pieArea.getY();

    ??// g2.clip(clipArea);
    ??Composite originalComposite = g2.getComposite();
    ??g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
    ????getForegroundAlpha()));
    ??
    ??//把數據源每個主鍵對應的值加起來
    ??double totalValue = DatasetUtilities.calculatePieDatasetTotal(dataset);
    ??
    ??//遍歷列表的時候用到
    ??double runningTotal = 0;
    ??
    ??//如果高度<0退出
    ??if (depth < 0) {
    ???return; // if depth is negative don't draw anything
    ??}

    ??//弧形的列表(用于添加主鍵的值對應的弧形)
    ??ArrayList arcList = new ArrayList();
    ??//定義一個弧行
    ??Arc2D.Double arc;
    ??//定義油漆桶,用來填充顏色
    ??Paint paint;
    ??Paint outlinePaint;
    ??//用于描繪輪廓的樣式
    ??Stroke outlineStroke;
    ??
    ??//遍歷取出主鍵的值對應的弧形放到弧形列表
    ??Iterator iterator = sectionKeys.iterator();
    ??while (iterator.hasNext()) {
    ???// 取出主鍵的值
    ???Comparable currentKey = (Comparable) iterator.next();???
    ???Number dataValue = dataset.getValue(currentKey);
    ???
    ???// 如果主鍵的值為空,則弧形為空
    ???if (dataValue == null) {
    ????arcList.add(null);
    ????continue;
    ???}
    ???
    ???// 如果主鍵的值<=0,則弧形為空
    ???double value = dataValue.doubleValue();
    ???if (value <= 0) {
    ????arcList.add(null);
    ????continue;
    ???}
    ???
    ???//弧形的開始角度(從該角度算起,相當于360度的0度)
    ???double startAngle = getStartAngle();
    ???//方向
    ???double direction = getDirection().getFactor();
    ???//角度大小1(該主鍵對應的弧形的開始角度)
    ???double angle1 = startAngle + (direction * (runningTotal * 360))
    ?????/ totalValue;
    ???//角度大小2(該主鍵對應的弧形的結束角度)
    ???double angle2 = startAngle
    ?????+ (direction * (runningTotal + value) * 360) / totalValue;
    ???
    ???//如果弧形的角度大小<0.00001則該弧形為空
    ???if (Math.abs(angle2 - angle1) > getMinimumArcAngleToDraw()) {
    ????arcList.add(new Arc2D.Double(arcX, arcY + depth, pieArea
    ??????.getWidth(), pieArea.getHeight() - depth, angle1,
    ??????angle2 - angle1, Arc2D.PIE));
    ???} else {
    ????arcList.add(null);
    ???}
    ???
    ???//轉入下個弧形(主鍵對應的圖形)
    ???runningTotal += value;
    ??}
    ??
    ??//取出剪裁的圖形(500*300)
    ??Shape oldClip = g2.getClip();

    ??//3D餅圖中上面的橢圓
    ??Ellipse2D top = new Ellipse2D.Double(pieArea.getX(), pieArea.getY(),
    ????pieArea.getWidth(), pieArea.getHeight() - depth);
    ??// 3D餅圖中底部的橢圓
    ??Ellipse2D bottom = new Ellipse2D.Double(pieArea.getX(), pieArea.getY()
    ????+ depth, pieArea.getWidth(), pieArea.getHeight() - depth);??
    ??//底部的長方形
    ??Rectangle2D lower = new Rectangle2D.Double(top.getX(),
    ????top.getCenterY(), pieArea.getWidth(), bottom.getMaxY()
    ??????- top.getCenterY());
    ??//上部的長方形
    ??Rectangle2D upper = new Rectangle2D.Double(pieArea.getX(), top.getY(),
    ????pieArea.getWidth(), bottom.getCenterY() - top.getY());
    ??
    ??// Area幾何建模對象
    ??Area a = new Area(top);
    ??a.add(new Area(lower));
    ??Area b = new Area(bottom);
    ??b.add(new Area(upper));
    ??Area pie = new Area(a);
    ??// 通過幾何建模對象對上面的圖形進行交叉運算
    ??pie.intersect(b);

    ??Area front = new Area(pie);
    ??// 相減運算
    ??front.subtract(new Area(top));

    ??Area back = new Area(pie);
    ??// 相減運算
    ??back.subtract(new Area(bottom));

    ??// draw the bottom circle
    ??int[] xs;
    ??int[] ys;
    ??outlinePaint = getSectionOutlinePaint(0);
    ??arc = new Arc2D.Double(arcX, arcY + depth, pieArea.getWidth(), pieArea
    ????.getHeight()
    ????- depth, 0, 360, Arc2D.PIE);

    ??// 畫出3D餅圖下部的橢圓的弧形和有該圖形的高度組成的多邊形
    ??int categoryCount = arcList.size();
    ??for (int categoryIndex = 0; categoryIndex < categoryCount; categoryIndex++) {
    ???//取出弧形
    ???arc = (Arc2D.Double) arcList.get(categoryIndex);
    ???if (arc == null) {
    ????continue;
    ???}
    ???paint = getSectionPaint(categoryIndex);
    ???outlinePaint = getSectionOutlinePaint(categoryIndex);
    ???outlineStroke = getSectionOutlineStroke(categoryIndex);
    ???g2.setPaint(paint);
    ???//填充弧形
    ???g2.fill(arc);
    ???g2.setPaint(outlinePaint);
    ???g2.setStroke(outlineStroke);
    ???//繪制弧形
    ???g2.draw(arc);
    ???g2.setPaint(paint);
    ???
    ???//取得弧形的開始點
    ???Point2D p1 = arc.getStartPoint();

    ???// 定義多邊形(弧形的高度組成的圖形)
    ???xs = new int[] { (int) arc.getCenterX(), (int) arc.getCenterX(),
    ?????(int) p1.getX(), (int) p1.getX() };
    ???ys = new int[] { (int) arc.getCenterY(),
    ?????(int) arc.getCenterY() - depth, (int) p1.getY() - depth,
    ?????(int) p1.getY() };???
    ???Polygon polygon = new Polygon(
    ?????xs, //多邊形x坐標點的數組
    ?????ys, //多邊形y坐標點的數組
    ?????4 //數組大小
    ?????);
    ???g2.setPaint(java.awt.Color.lightGray);
    ???g2.fill(polygon);
    ???g2.setPaint(outlinePaint);
    ???g2.setStroke(outlineStroke);
    ???//繪制該多邊形
    ???g2.draw(polygon);
    ???g2.setPaint(paint);

    ??}

    ??g2.setPaint(Color.gray);
    ??g2.fill(back);
    ??g2.fill(front);

    ??// cycle through once drawing only the sides at the back...
    ??// 描出背部的邊
    ??int cat = 0;
    ??iterator = arcList.iterator();
    ??while (iterator.hasNext()) {
    ???Arc2D segment = (Arc2D) iterator.next();
    ???if (segment != null) {
    ????paint = getSectionPaint(cat);
    ????outlinePaint = getSectionOutlinePaint(cat);
    ????outlineStroke = getSectionOutlineStroke(cat);
    ????drawSide(g2, pieArea, segment, front, back, paint,
    ??????outlinePaint, outlineStroke, false, true);
    ???}
    ???cat++;
    ??}

    ??// cycle through again drawing only the sides at the front...
    ??// 描出前面的邊
    ??cat = 0;
    ??iterator = arcList.iterator();
    ??while (iterator.hasNext()) {
    ???Arc2D segment = (Arc2D) iterator.next();
    ???if (segment != null) {
    ????paint = getSectionPaint(cat);
    ????outlinePaint = getSectionOutlinePaint(cat);
    ????outlineStroke = getSectionOutlineStroke(cat);
    ????drawSide(g2, pieArea, segment, front, back, paint,
    ??????outlinePaint, outlineStroke, true, false);
    ???}
    ???cat++;
    ??}

    ??g2.setClip(oldClip);

    ??// 畫出3D餅圖上部的橢圓的弧形和相關的標簽鏈接和底部的說明(tooltip)
    ??Arc2D upperArc;
    ??for (int sectionIndex = 0; sectionIndex < categoryCount; sectionIndex++) {
    ???//取出弧形
    ???arc = (Arc2D.Double) arcList.get(sectionIndex);
    ???if (arc == null) {
    ????continue;
    ???}
    ???//定義3D餅圖上部的橢圓的弧形
    ???upperArc = new Arc2D.Double(arcX, arcY, pieArea.getWidth(), pieArea
    ?????.getHeight()
    ?????- depth,
    ?????arc.getAngleStart(), //開始角度
    ?????arc.getAngleExtent(), //角度大小
    ?????Arc2D.PIE);
    ???//g2圖形對象所需的油漆桶
    ???paint = getSectionPaint(sectionIndex);
    ???//g2圖形對象所需的輪廓油漆桶
    ???outlinePaint = getSectionOutlinePaint(sectionIndex);
    ???//g2圖形對象所需的輪廓樣式
    ???outlineStroke = getSectionOutlineStroke(sectionIndex);
    ???g2.setPaint(paint);
    ???//往g2圖形對象中填充弧形
    ???g2.fill(upperArc);
    ???g2.setStroke(outlineStroke);
    ???g2.setPaint(outlinePaint);
    ???//繪制弧形
    ???g2.draw(upperArc);

    ???// 為該部分弧形添加說明欄(tooltip)和url鏈接
    ???Comparable currentKey = (Comparable) sectionKeys.get(sectionIndex);
    ???if (info != null) {
    ????EntityCollection entities = info.getOwner()
    ??????.getEntityCollection();
    ????if (entities != null) {
    ?????String tip = null;
    ?????PieToolTipGenerator tipster = getToolTipGenerator();
    ?????if (tipster != null) {
    ??????// @mgs: using the method's return value was missing
    ??????tip = tipster.generateToolTip(dataset, currentKey);
    ?????}
    ?????String url = null;
    ?????if (getURLGenerator() != null) {
    ??????url = getURLGenerator().generateURL(dataset,
    ????????currentKey, getPieIndex());
    ?????}
    ?????PieSectionEntity entity = new PieSectionEntity(upperArc,
    ???????dataset, getPieIndex(), sectionIndex, currentKey,
    ???????tip, url);
    ?????entities.add(entity);
    ????}
    ???}
    ???
    ???List keys = dataset.getKeys();
    ???//繪制標簽的長方形
    ???Rectangle2D adjustedPlotArea = new Rectangle2D.Double(
    ?????originalPlotArea.getX(), originalPlotArea.getY(),
    ?????originalPlotArea.getWidth(), originalPlotArea.getHeight()
    ???????- depth);
    ???//繪制標簽(如:Perl=1的Textbox)
    ???drawLabels(g2, keys, totalValue, adjustedPlotArea, linkArea, state);
    ??}

    ??g2.setClip(savedClip);
    ??g2.setComposite(originalComposite);
    ??//繪制輪廓
    ??drawOutline(g2, originalPlotArea);
    ?}
    ?
    4.3D柱狀圖的繪制函數(現在的注釋還不夠全面,也可能存在錯誤)
    ??? /**
    ???? * Draws a 3D bar to represent one data item.
    ???? *
    ???? * @param g2? the graphics device.
    ???? * @param state? the renderer state.
    ???? * @param dataArea? the area for plotting the data.
    ???? * @param plot? the plot.
    ???? * @param domainAxis? the domain axis.
    ???? * @param rangeAxis? the range axis.
    ???? * @param dataset? the dataset.
    ???? * @param row? the row index (zero-based).
    ???? * @param column? the column index (zero-based).
    ???? * @param pass? the pass index.
    ???? */
    ??? public void drawItem(Graphics2D g2,
    ???????????????????????? CategoryItemRendererState state,
    ???????????????????????? Rectangle2D dataArea,
    ???????????????????????? CategoryPlot plot,
    ???????????????????????? CategoryAxis domainAxis,
    ???????????????????????? ValueAxis rangeAxis,
    ???????????????????????? CategoryDataset dataset,
    ???????????????????????? int row,
    ???????????????????????? int column,
    ???????????????????????? int pass) {
    ???
    ??????? // check the value we are plotting...
    ??????? Number dataValue = dataset.getValue(row, column);
    ??????? if (dataValue == null) {
    ??????????? return;
    ??????? }
    ???????
    ??????? double value = dataValue.doubleValue();
    ???????
    ??????? Rectangle2D adjusted = new Rectangle2D.Double(
    ??????????? dataArea.getX(),
    ??????????? dataArea.getY() + getYOffset(),
    ??????????? dataArea.getWidth() - getXOffset(),
    ??????????? dataArea.getHeight() - getYOffset()
    ??????? );

    ??????? PlotOrientation orientation = plot.getOrientation();
    ???????
    ??????? double barW0 = calculateBarW0(
    ??????????? plot, orientation, adjusted, domainAxis, state, row, column
    ??????? );
    ??????? double[] barL0L1 = calculateBarL0L1(value);
    ??????? if (barL0L1 == null) {
    ??????????? return;? // the bar is not visible
    ??????? }

    ??????? RectangleEdge edge = plot.getRangeAxisEdge();
    ??????? double transL0 = rangeAxis.valueToJava2D(barL0L1[0], adjusted, edge);
    ??????? double transL1 = rangeAxis.valueToJava2D(barL0L1[1], adjusted, edge);
    ??????? double barL0 = Math.min(transL0, transL1);
    ??????? double barLength = Math.abs(transL1 - transL0);
    ???????
    ??????? // draw the bar...
    ??????? //柱子的正視圖
    ??????? Rectangle2D bar = null;
    ??????? if (orientation == PlotOrientation.HORIZONTAL) {
    ??????????? bar = new Rectangle2D.Double(
    ??????????????? barL0, barW0, barLength, state.getBarWidth()
    ??????????? );
    ??????? }
    ??????? else {
    ??????????? bar = new Rectangle2D.Double(
    ??????????????? barW0, barL0, state.getBarWidth(), barLength
    ??????????? );
    ??????? }
    ??????? Paint itemPaint = getItemPaint(row, column);
    ??????? g2.setPaint(itemPaint);
    ??????? g2.fill(bar);

    ??????? // 柱子的俯視圖上的四個點的x坐標值
    ??????? double x0 = bar.getMinX();
    ??????? double x1 = x0 + getXOffset(); //x0+12
    ??????? double x2 = bar.getMaxX();
    ??????? double x3 = x2 + getXOffset(); //x2+12
    ??????? // 柱子的右視圖上的四個點的y坐標值
    ??????? double y0 = bar.getMinY() - getYOffset(); //正視圖的最小y值-8
    ??????? double y1 = bar.getMinY();
    ??????? double y2 = bar.getMaxY() - getYOffset(); //正視圖的最大y值-8
    ??????? double y3 = bar.getMaxY();
    ???????
    ??????? GeneralPath bar3dRight = null;
    ??????? GeneralPath bar3dTop = null;
    ??????? // 柱子的右視圖
    ??????? if (barLength > 0.0) {
    ??????????? bar3dRight = new GeneralPath();
    ??????????? bar3dRight.moveTo((float) x2, (float) y3);
    ??????????? bar3dRight.lineTo((float) x2, (float) y1);
    ??????????? bar3dRight.lineTo((float) x3, (float) y0);
    ??????????? bar3dRight.lineTo((float) x3, (float) y2);
    ??????????? bar3dRight.closePath();

    ??????????? if (itemPaint instanceof Color) {
    ??????????????? g2.setPaint(((Color) itemPaint).darker());
    ??????????? }
    ??????????? g2.fill(bar3dRight);
    ??????? }
    ??????? // 柱子的俯視圖
    ??????? bar3dTop = new GeneralPath();
    ??????? bar3dTop.moveTo((float) x0, (float) y1);
    ??????? bar3dTop.lineTo((float) x1, (float) y0);
    ??????? bar3dTop.lineTo((float) x3, (float) y0);
    ??????? bar3dTop.lineTo((float) x2, (float) y1);
    ??????? bar3dTop.closePath();
    ??????? g2.fill(bar3dTop);

    ??????? //繪制3D柱狀圖
    ??????? if (isDrawBarOutline()
    ??????????????? && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {
    ??????????? g2.setStroke(getItemOutlineStroke(row, column));
    ??????????? g2.setPaint(getItemOutlinePaint(row, column));
    ??????????? g2.draw(bar);
    ??????????? if (bar3dRight != null) {
    ??????????????? g2.draw(bar3dRight);
    ??????????? }
    ??????????? if (bar3dTop != null) {
    ??????????????? g2.draw(bar3dTop);
    ??????????? }
    ??????? }

    ??????? //繪制標簽
    ??????? CategoryItemLabelGenerator generator
    ??????????? = getItemLabelGenerator(row, column);
    ??????? if (generator != null && isItemLabelVisible(row, column)) {
    ??????????? drawItemLabel(
    ??????????????? g2, dataset, row, column, plot, generator, bar, (value < 0.0)
    ??????????? );
    ??????? }???????

    ??????? // add an item entity, if this information is being collected
    ??????? EntityCollection entities = state.getEntityCollection();
    ??????? if (entities != null) {
    ??????????? GeneralPath barOutline = new GeneralPath();
    ??????????? barOutline.moveTo((float) x0, (float) y3);
    ??????????? barOutline.lineTo((float) x0, (float) y1);
    ??????????? barOutline.lineTo((float) x1, (float) y0);
    ??????????? barOutline.lineTo((float) x3, (float) y0);
    ??????????? barOutline.lineTo((float) x3, (float) y2);
    ??????????? barOutline.lineTo((float) x2, (float) y3);
    ??????????? barOutline.closePath();
    ??????????? addItemEntity(entities, dataset, row, column, barOutline);
    ??????? }

    ??? }

    posted @ 2006-05-12 15:22 JGAO編程隨筆 閱讀(1473) | 評論 (0)編輯 收藏

    搜尋父結點(獲得用戶部門信息)

    String usercodemessage = "";
    ?/**
    ? * 搜尋父結點(獲得用戶部門信息)
    ? */
    ?public String searchTreeFatherNood(TCsDept tCsDept) {??
    ??if (tCsDept.getFathercode().equals("")) {
    ???usercodemessage = tCsDept.getDeptname() + "/" + usercodemessage;
    ??} else {
    ???usercodemessage = tCsDept.getDeptname() + "/" + usercodemessage;
    ???TCsDept tCsDept2 = (TCsDept) userDao.fetchQuerister().loadObject(
    ?????TCsDept.class, tCsDept.getFathercode());???
    ???searchTreeFatherNood(tCsDept2);
    ??}
    ??return usercodemessage;
    ?}

    posted @ 2006-03-31 11:42 JGAO編程隨筆 閱讀(246) | 評論 (1)編輯 收藏

    my hibernate Optimistic Locking configuration

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "<hibernate-mapping>
    <class name="com.jgao.forum.modelbean.Jgaoforum" schema="GAOFORUM" table="JGAOFORUM" dynamic-update="true" dynamic-insert="true" optimistic-lock="version">
    <id column="FORUMID" name="forumid" type="java.lang.String">
    <generator class="uuid.hex"/>
    </id>
    <version column="VERSION" name="version" type="java.lang.Long" />
    <property column="NAME" length="255" name="name" type="java.lang.String"/>
    <property column="DESCRIPTION" length="2000" name="description" type="java.lang.String"/>
    <property column="MODIFIEDDATE" length="15" name="modifieddate" type="java.lang.String"/>
    <property column="CREATIONDATE" length="15" name="creationdate" type="java.lang.String"/>
    <property column="MODERATED" length="22" name="moderated" not-null="true" type="java.lang.Long"/>
    </class>
    </hibernate-mapping>

    posted @ 2006-03-20 20:10 JGAO編程隨筆 閱讀(233) | 評論 (0)編輯 收藏

    <2006年3月>
    2627281234
    567891011
    12131415161718
    19202122232425
    2627282930311
    2345678

    導航

    統計

    常用鏈接

    留言簿(1)

    隨筆檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 黄页网站在线视频免费| 思思99re66在线精品免费观看| 亚洲日本成本人观看| 亚洲天堂视频在线观看| 亚洲精品视频在线看| 嫩草视频在线免费观看| 99久久免费精品视频| 99精品视频在线观看免费| 在线精品自拍亚洲第一区| 国产亚洲国产bv网站在线| 亚洲成a人片77777老司机| 91麻豆国产自产在线观看亚洲| 国产美女无遮挡免费视频网站| 18禁黄网站禁片免费观看不卡| a成人毛片免费观看| 特级毛片aaaa免费观看| 相泽南亚洲一区二区在线播放| 亚洲免费福利在线视频| 亚洲国产成人精品电影| 亚洲蜜芽在线精品一区| 久久亚洲国产精品| 亚洲伊人久久精品影院| 亚洲欧洲自拍拍偷精品 美利坚 | 国产无遮挡又黄又爽免费视频| 国产一卡二卡四卡免费| 中文字幕免费在线观看| 99热在线精品免费播放6| 两个人看的www免费视频中文| 成人无码精品1区2区3区免费看| 欧亚一级毛片免费看| 日本黄页网址在线看免费不卡| 国产精品亚洲一区二区三区久久| 亚洲无人区码一二三码区别图片 | 免费无码又爽又高潮视频| 最近中文字幕免费mv视频8| 色婷婷7777免费视频在线观看| 国产福利在线观看免费第一福利| 国产精品入口麻豆免费观看| 99久久久精品免费观看国产| 久久精品免费全国观看国产| 成年女人毛片免费播放人|