方枪枪的java世界

不要因为风雨飘落就停止了你的脚步,真正的得失就在你的心中。 做喜欢做的事,不轻言放弃!

#

javascript 学习(二)

01、用构造函数创建对象
        function Student(name,age,grade)   
        {
            this.name = name;
            this.age = age;
            this.grade = grade;
        }

02、直接创建对象
        
        var book = new Object();
        
        book.title = "精通Spring";
        
        book.chapter1= new Object();
        book.chapter1.title="第一章";
        book.chapter1.pages=20;
        
        book.chapter2 = {title:"第二章",pages:30};

        delete book.chapter2;

03、原型对象:每一个类都有一个原型对象,每一个该类的对象都继承其原型对象的所有属性;
        要为一个类原型对象,需要将构造函数的prototype设置为适当的对象。
        此后,用构造函数初始化一个对象的时候,javascript会自动将该对象作为新建对象的原型对象;
        继承在查询一个属性值时自动发生的,因此使用原型对象可以很大程度上减少每个对象对内存的需求量;

        即使属性是在对象创建后才添加到原型对象中,对象仍然能够继承这些属性。
04、类 方 法:通过设置类的一个属性来实现;使用类名存取;类变量同理;
        实例方法:通过设置原型对象的一个属性实现;通过this来存取;
        对象方法:通过设置某个对象的一个属性来实现,只能由该对象来存取。


posted @ 2008-04-07 23:42 做强大的自己 阅读(146) | 评论 (0)编辑 收藏

javascript 学习(一)

01、引用javascript文件和将脚本文件直接插入到script标签的效果相同;

02、html的超链接标签<a>的href属性除了支持http、mailto协议外,还支持javascript协议。

03、<head></head>之间引入脚本文件 ?

04、全局变量是全局对象的一个属性;所有预定义的函数和属性都是全局变量的属性;顶层代码中使用this引用该全局对象;    

        局部变量是局部对象的一个属性;

        可见所有javascript函数运行在自己独有的执行环境中,而且具有自己的调用对象,并在调用对象中定义局部变量;

05、原始类型使用值来进行操作的;

        引用类型则是使用引用来进行操作的;

        数字型和逻辑型数据都是由小的、固定数量的字节构成的原始类型;

        对象、数组、函数都是引用类型,这些属性可以包含任意多个属性或元素,不像固定大小的原始数值那样易于操作。另外,由于对象和数组所占用空间可能非常大,使用值来操作这些数据毫无意义,而且这样做可能会产生占用大量内存空间的低效率的复制和比较。

06、&nbsp; 空格

07、函数的隐含参数数组对象arguments,用于处理不定个数的参数很方便。

08、客户端和服务器之间通信时,许多常见的非字母数字字符(如空格)不能以原来的格式传输,只允许使用较少的字母、数字和符号传输。为了使用其他字符,字符必须使用特殊的符号(%)和十六进制的ascii码进行编码,如空格是十六进制的20(ascii值十进制的32),其编码为%20。在浏览器历史记录后url中可以见到这个符号。

        encodeURI和decodeURI,URI编码;

        escape和unescape,对字符串编码,不要对URI编码,使用encodeURI。

09、eval("表达式")执行动态表达式,效果和直接执行程序效果一样;

 

 

posted @ 2008-04-07 23:28 做强大的自己 阅读(172) | 评论 (0)编辑 收藏

cell 报表制作脚本举例

 

<%@ page contentType="text/html;charset=GBK"%>
<%@ taglib uri="/tags/web-html" prefix="html"%>
<%@ taglib uri="/tags/web-tianhe" prefix="templates"%>
<%@ page import="java.math.BigDecimal"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.Date"%>


<script language="Jscript">

function setfilename()
{
  filen="jsp/hr/personnel/Personnelreport.cll";  
  return filen;
}
function filldata()
{
<%
   List bodyList=(List)request.getAttribute("bodyList");  //表体数据
   Map headTailMap=(Map)request.getAttribute("headTailMap");  //表头表尾数据
  
   int len = bodyList.size();
   String title= (String) headTailMap.get("title");//标题
      String userName=(String)headTailMap.get("userName");//制表人
      String date=(String)headTailMap.get("dateId");//制表时间
%>
     sheet = <%=0%>;
  content_col=1;
  //设置某页行数
  CellRpt.SetRows(<%=len+4+1%>,sheet);//设置某页行数(行数,页号)
  CellRpt.SetCols(15,sheet);//设置某页列数(列数,页号)
  CellRpt.PrintSetOrient(1);//设置进纸方式为横放

  CellRpt.MergeCells(1,1,15,1);//将指定区域的单元格组合(区域起始点列号,行号,区域结束点列号,行号)
  CellRpt.SetCellFontStyle(1,1,sheet,2);//设置指定单元格的字体风格(列号,行号,页号,字体风格)
   CellRpt.SetCellFontSize(1,1,sheet,20);//设置单元格字体大小(列号,行号,页号,字号)
  CellRpt.SetCellAlign(1,1,sheet,36);//设置指定单元格的对齐方式(列号,行号,页号,参数)
  CellRpt.S(1,1,sheet,"<%=title%>");

  CellRpt.MergeCells(1,2,1,2);
  CellRpt.SetCellFontStyle(1,2,sheet,3);
   CellRpt.SetCellFontSize(1,2,sheet,10);
  CellRpt.SetCellAlign(1,2,sheet,36);
  CellRpt.S(1,2,sheet,"部门");

  CellRpt.MergeCells(2,2,2,2);
  CellRpt.SetCellFontStyle(2,2,sheet,3);
   CellRpt.SetCellFontSize(2,2,sheet,10);
  CellRpt.SetCellAlign(2,2,sheet,36);
  CellRpt.S(2,2,sheet,"姓名");

  CellRpt.MergeCells(3,2,3,2);
  CellRpt.SetCellFontStyle(3,2,sheet,3);
   CellRpt.SetCellFontSize(3,2,sheet,10);
  CellRpt.SetCellAlign(3,2,sheet,36);
  CellRpt.S(3,2,sheet,"性别");

  CellRpt.MergeCells(4,2,4,2);
  CellRpt.SetCellFontStyle(4,2,sheet,3);
   CellRpt.SetCellFontSize(4,2,sheet,10);
  CellRpt.SetCellAlign(4,2,sheet,36);
  CellRpt.S(4,2,sheet,"年龄");

  CellRpt.MergeCells(5,2,5,2);
  CellRpt.SetCellFontStyle(5,2,sheet,3);
   CellRpt.SetCellFontSize(5,2,sheet,10);
  CellRpt.SetCellAlign(5,2,sheet,36);
  CellRpt.S(5,2,sheet,"政治面貌");

  CellRpt.MergeCells(6,2,6,2);
  CellRpt.SetCellFontStyle(6,2,sheet,3);
   CellRpt.SetCellFontSize(6,2,sheet,10);
  CellRpt.SetCellAlign(6,2,sheet,36);
  CellRpt.S(6,2,sheet,"学历");

  CellRpt.MergeCells(7,2,7,2);
  CellRpt.SetCellFontStyle(7,2,sheet,3);
   CellRpt.SetCellFontSize(7,2,sheet,10);
  CellRpt.SetCellAlign(7,2,sheet,36);
  CellRpt.S(7,2,sheet,"专业技术名称");

  CellRpt.MergeCells(8,2,8,2);
  CellRpt.SetCellFontStyle(8,2,sheet,3);
   CellRpt.SetCellFontSize(8,2,sheet,10);
  CellRpt.SetCellAlign(8,2,sheet,36);
  CellRpt.S(8,2,sheet,"职业技能名称");

  CellRpt.MergeCells(9,2,9,2);
  CellRpt.SetCellFontStyle(9,2,sheet,3);
   CellRpt.SetCellFontSize(9,2,sheet,10);
  CellRpt.SetCellAlign(9,2,sheet,36);
  CellRpt.S(9,2,sheet,"出生日期");

  CellRpt.MergeCells(10,2,10,2);
  CellRpt.SetCellFontStyle(10,2,sheet,3);
   CellRpt.SetCellFontSize(10,2,sheet,10);
  CellRpt.SetCellAlign(10,2,sheet,36);
  CellRpt.S(10,2,sheet,"入职时间");
 
  CellRpt.MergeCells(11,2,11,2);
  CellRpt.SetCellFontStyle(11,2,sheet,3);
   CellRpt.SetCellFontSize(11,2,sheet,10);
  CellRpt.SetCellAlign(11,2,sheet,36);
  CellRpt.S(11,2,sheet,"家庭地址");
 
  CellRpt.MergeCells(12,2,12,2);
  CellRpt.SetCellFontStyle(12,2,sheet,3);
   CellRpt.SetCellFontSize(12,2,sheet,10);
  CellRpt.SetCellAlign(12,2,sheet,36);
  CellRpt.S(12,2,sheet,"办公电话");
 
  CellRpt.MergeCells(13,2,13,2);
  CellRpt.SetCellFontStyle(13,2,sheet,3);
   CellRpt.SetCellFontSize(13,2,sheet,10);
  CellRpt.SetCellAlign(13,2,sheet,36);
  CellRpt.S(13,2,sheet,"移动电话");
 
  CellRpt.MergeCells(14,2,14,2);
  CellRpt.SetCellFontStyle(14,2,sheet,3);
   CellRpt.SetCellFontSize(14,2,sheet,10);
  CellRpt.SetCellAlign(14,2,sheet,36);
  CellRpt.S(14,2,sheet,"员工状态");
 
     content_row=3;

<%
  BigDecimal sumEmpNum = new BigDecimal(bodyList.size());

        for(int i = 0;i < bodyList.size();i++){
       Map  bodyMap = (Map) bodyList.get(i);
       String orgName = (String)bodyMap.get("ORGAN_NAME");//部门
    String empName = (String)bodyMap.get("EMP_NAME");//员工姓名
    String sex = (String)bodyMap.get("SEX");//性别
    String policital = (String)bodyMap.get("POLICITAL_STATUS");//政治面貌
    String edu = (String)bodyMap.get("EDUCATION");//学历
    String tName = (String)bodyMap.get("NAME");//专业技术名称
    String skillName = (String)bodyMap.get("SKILL_POST_NAME");//职业技能名称
    String birthday = (String)bodyMap.get("BIRTHDAY");//生日
    String entryDay = (String)bodyMap.get("ENTRY_ENTERPRISE_DAT");//入职时间
    String addr = (String)bodyMap.get("ADDRESS");//家庭住址
    String officePhone = (String)bodyMap.get("OFFICE_PHONE");//办公电话
    String mobilePhone = (String)bodyMap.get("MOBILE_PHONE");//移动电话
    String state = (String)bodyMap.get("STATE");//员工状态
    String ageStr = "";
    if(sex == null || "".equals(sex)){
     sex = "";
    }else{
     switch(Integer.parseInt(sex)){
     case 0 : sex="男";break;
     case 1 : sex="女";break;
     } 
    }
    if(policital == null || "".equals(policital)){
     policital = "";
    }else{
     switch(Integer.parseInt(policital)){
     case 1 : policital="工人";break;
     case 2 : policital="农民";break;
     case 3 : policital="知识分子";break;
     case 4 : policital="群众";break;
     } 
    }
    if(edu == null || "".equals(edu)){
     edu = "";
    }else{
     switch(Integer.parseInt(edu)){
     case 1 : edu="小学";break;
     case 2 : edu="初中";break;
     case 3 : edu="高中";break;
     case 4 : edu="大学专科";break;
     case 5 : edu="大学本科";break;
     case 6 : edu="硕士";break;
     case 7 : edu="博士";break;
     } 
    }
    if(skillName == null || "".equals(skillName)){
     skillName = "";
    }else{
     switch(Integer.parseInt(skillName)){
     case 1 : skillName="企业人力资源管理";break;
     case 2 : skillName="计算机操作";break;
     case 3 : skillName="仓储工";break;
     case 4 : skillName="企业经营管理";break;
     case 5 : skillName="秘书";break;
     case 6 : skillName="物流管理";break;
     case 7 : skillName="卷烟商品营销";break;
     case 8 : skillName="客户服务管理";break;
     case 9 : skillName="企业信息管理";break;
     case 10 : skillName="汽车驾驶";break;
     case 11 : skillName="营业员";break;
     } 
    }
    if(birthday == null || "".equals(birthday)){
     birthday = "";
    }else{
     String yearBir = birthday.substring(0,4);
     String dateNow = new Date().toString();
     String yearNow = dateNow.substring(dateNow.length()-4,dateNow.length());
     int ageInt = Integer.parseInt(yearNow) - Integer.parseInt(yearBir);
     ageStr = String.valueOf(ageInt); 
    }
%>
        content_col=1;
   CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
  CellRpt.SetCellAlign(content_col,content_row,sheet,33);
  CellRpt.S(content_col,content_row,sheet,"<%=orgName%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,33);
  CellRpt.S(content_col,content_row,sheet,"<%=empName%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,33);
  CellRpt.S(content_col,content_row,sheet,"<%=sex%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=ageStr%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=policital%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=edu%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=tName%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=skillName%>");
  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=birthday%>");
  content_col++;
 
  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=entryDay%>");
  content_col++;
 
  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=addr%>");
  content_col++;
 
  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=officePhone%>");
  content_col++;
 
  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=mobilePhone%>");
  content_col++;
 
  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=state%>");

  content_row++;
<%

}
%>
  content_col=1;
  CellRpt.MergeCells(content_col,content_row,content_col,content_row);
  CellRpt.SetCellFontStyle(content_col,content_row,sheet,0);
  CellRpt.SetCellAlign(content_col,content_row,sheet,33);
  CellRpt.S(content_col,content_row,sheet,"合计");

  content_col++;

  CellRpt.SetCellFontSize(content_col,content_row,sheet,10);
   CellRpt.SetCellAlign(content_col,content_row,sheet,34);
  CellRpt.S(content_col,content_row,sheet,"<%=sumEmpNum%>(人)");//总人数

 
  content_row++;
 
 
  CellRpt.MergeCells(1,content_row,3,content_row);
  CellRpt.SetCellFontSize(1,content_row,sheet,10);
   CellRpt.SetCellAlign(1,content_row,sheet,33);
  CellRpt.S(1,content_row,sheet,"制表人:"+"<%=userName%>");

  CellRpt.MergeCells(12,content_row,14,content_row);
  CellRpt.SetCellFontSize(12,content_row,sheet,10);
   CellRpt.SetCellAlign(12,content_row,sheet,34);
  CellRpt.S(12,content_row,sheet,"制表日期:"+"<%=date%>");

   var line_rowBegin=2; //从第二行开始
  var line_rowEnd=CellRpt.getRows(sheet)-2; //画到倒数第三行
  var line_colBegin=1; //从第一列开始
  var line_colEnd=CellRpt.getCols(sheet);//画到最后一列
  CellRpt.DrawGridLine(line_colBegin, line_rowBegin, line_colEnd,line_rowEnd, 0, 2,-1);//所有框画细线
 
  //打印设置
   CellRpt.PrintRange(1,1,CellRpt.getCols(sheet),CellRpt.getRows(sheet));
  CellRpt.PrintSetTopTitle(1,6);
  CellRpt.PrintSetBottomTitle(content_row+1,content_row+1);
  CellRpt.PrintSetOrient(1);//打印方向:1为横向,0为纵向
}

</script>

posted @ 2008-04-05 23:58 做强大的自己 阅读(706) | 评论 (0)编辑 收藏

SWT/JFace入门指南之初步体验widget

从Widget和Control开始

  Widget是Control的父类,而Control是我们使用的大多数部件的父类。

  在org.eclipse.swt.widgets中定义了众多的widget,甚至我们前面介绍的Shell也被当成widget的一种。

  因为可用的widget如此之多,所以我大概没有办法全部一一介绍。在这一节中,我会介绍几种常用的widget。相信善于触类旁通的你通过这些极为简略的介绍应该可以开始使用各种widget,在使用中不断完善自己的认识。

  首先我们来介绍Widget。它是一个抽象类,也是所有widget的父类。通过介绍这个类,我们可以得出这所有widget的一些共有特性。

  Widget的方法中dispose()方法我们在以前曾经见到过,调用这个方法时候,所谓的接收者(receiver,譬如我们这样写:awidget.dispose(),那么awidget就是接收者,而这句话所处的对象称为调用者)和接收者中所包含的其他widget会释放它们所占用底层操作系统的资源。这也就是说你不必显式地为程序中创建的每个widget进行dispose()调用,而只需要确保最外层的widget(比如Display)进行了dispose()就可以了。

  另外还可以通过isDisposed()判断是否该widget(接收者)已经进行了dispose。

  Widget中的getStyle()方法得到widget的风格,而getDisplay()得到所处的Display对象。

  此外Widget中还有两个重要方法getData()和setData(),这两个方法允许我们为一个widget附加其他的信息。特别是在你需要跨模块传递widget的时候,这个功能显得非常有用。比如如果一个文本框中显示了一段文章中的某句话,如果我们同时希望把这整篇文章的题目和作者附加上的话可以这样写:

  atext.setData("title","I Have A Dream");
  atext.setData("author","Martin Luther King");

  在程序的其他部分可以用atext.getData(“title”)得到这篇文章的题目,或者用atext.getData("author")得到作者。

  在前面我们提到过,Control是今后我们所使用大部分widget的父类。

  创建部件

  和创建其他java object一样,我们通过使用new操作符创建部件的实例。有一点比较特殊的可能你需要使用带参数的构造函数进行new操作。类似下面的程序:

  Text text=new Text(shell,SWT.CENTER);

  这种方法适用于几乎所有的widget,其中第一个参数是父widget,也就是指明了该widget需要被放置道另外哪一个widget之中,而第二个参数是这个widget的风格。

  大小和位置

  仅仅创建一个部件并不足以让你看到它,因为一个部件初始的长和宽都是0。你还需要设定它的大小。你可以用setSize()或者setBounds()方法手动设定部件的大小,也可以让系统自动调整部件的大小到一个合适的值,这个值也被成为首选尺寸(preferred size)。

  可以通过调用pack()方法让系统调整控件大小。如果你希望系统自动调整,那么你需要首先设定控件需要表达的内容。举个例子来说,如果你的部件是一个文本框或者标签,你应该首先设定它所要显示的文本,这样系统可以通过文本的长度计算。

  对于部件的位置,同样可以使用setLocation()或者setBounds()进行设定。

  这里值得一提的是所谓的bounds,其实bounds可以看成是大小和尺寸的综合。比如setBounds(int x, int y,int width,int height)的参数中,x和y描述的是位置信息,而width和height描述了大小。

  隐藏与失效

  通过部件的setVisible方法可以控制部件进行隐藏或是显示。通过setEnabled方法可以控制部件是否有效。一个无效的部件不会对用户的任何动作作出响应。这两个方法的参数都是布尔型的。

  提示文本

  可以通过setToolTipText()方法设定部件的提示文本。

  几种常用的部件

  Label

  标签用来显示静态的文本或者图像。关于图像和色彩我会在后面的部分进行介绍。

  标签可以使用SWT.CENTER, SWT.LEFT, SWT.RIGHT中的一种指明文本的对齐方式(居中对齐,左对齐,右对齐)。

  你也可以通过设置标签属性为SWT. SEPARATOR 使标签成为一条分隔符。

  Text就是最简单的文本框,与标签一样,我们可以通过设定它的风格来表示它的对齐方式(SWT.CENTER,SWT.LEFT,SWT.RIGHT),另外还有其他一些用于文本支持的方法,比如insert(),paster(),copy(),setSelection(),selectAll()等,这些方法在后面介绍swt事件模式会进行更详细的介绍。

  Button

  在swt中,Button并不仅仅是按钮。构造时候定义的风格不同,所体现出的外观也不一样。

  如果风格定义成SWT.PUSH,它就是一个普通的按钮。

  如果定义为SWT.TOGGLE,它在被按下以后会保持按下的形状(而不会弹起来),直到鼠标再次在上面按一下才会回复弹起的形状。

  如果风格定义为SWT.ARROW,它是一个带箭头的按钮,箭头的指向可以选择SWT.LEFT,SWT.RIGHT,SWT.UP,SWT.DOWN中的一个。

  如果定义为SWT.CHECK,它是一个复选框。

  如果定义为SWT.RADIO,它是一个单选框。
  

posted @ 2008-04-05 23:06 做强大的自己 阅读(194) | 评论 (0)编辑 收藏

搭建 strut2+spring2 on java5 的开发框架(一)

 从http://struts.apache.org/2.x/下载struts2.0.11。
 
 使用tomcat5.0会报错如下:
 2008-04-05 20:00:20 StandardContext[/tianhe]Exception starting filter struts2
javax.xml.transform.TransformerFactoryConfigurationError: Provider org.apache.xalan.processor.TransformerFactoryImpl not found
 at javax.xml.transform.TransformerFactory.newInstance(Unknown Source)
   
解决 办法1:
 拷贝xalan.jar,xercesImpl.jar,serializer.jar,xml-apis.jar 到 应用的tomcat的common\endorsed目录
解决 办法2:     
 升级到tomcat5.5

这种异常很恶心.
出现的原因是因为jdk版本和tomcat版本的不匹配造成的.
解决的原因是用匹配的版本.
在此.推荐jdk1.5+jdk5.5.20搭配.

posted @ 2008-04-05 20:13 做强大的自己 阅读(153) | 评论 (0)编辑 收藏

仅列出标题
共4页: 上一页 1 2 3 4