|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
J2ME在手机游戏开发的作用也是无用质疑的。至于桌面程序,可能有人说java不行,界面不好看,但是请看看NetBeans和Eclipse吧,他们都是利用java开发的,而他们的界面是多么的华丽,所以界面决不是java的缺点。还有一个不得不提的优点就是大多java人员都挂在嘴边的java的跨平台性,目前这确实也是java优点之一。j2ee 用网页展现表格时,假如行数太多,偶然候必要把它们分红良多页.并且各行之间利用分歧的背景致来便利用户浏览.大概大概还必要排序。固然完成下面的功效都不难,可是假如利用Display标志库将可以年夜年夜简化开辟.它仿照google,baidu页面的作风,把很多行的表格分红各个页面,并供应了经常使用的功效。
数据模子是很复杂的美国总统JavaBean.它有3个复杂的String属性。
Java代码以下:
PagedData.java
importjava.util.ArrayList;
importjava.util.List;
publicclassPagedData{
privateListlist;
publicPagedData(){
list=newArrayList();
list.add(newPresident("Garfield","James","1881"));
list.add(newPresident("Arthur","Chester","1881-85"));
list.add(newPresident("Cleveland","Grover","1885-89"));
list.add(newPresident("Harrison","Benjamin","1889-93"));
list.add(newPresident("Cleveland","Grover","1893-97"));
list.add(newPresident("McKinley","William","1897-1901"));
list.add(newPresident("Roosevelt","Theodore","1901-09"));
list.add(newPresident("Taft","WilliamH.","1909-13"));
list.add(newPresident("Wilson","Woodrow","1913-21"));
list.add(newPresident("Jackson","Andrew","1829-37"));
list.add(newPresident("Harding","Warren","1921-23"));
list.add(newPresident("Coolidge","Calvin","1923-29"));
list.add(newPresident("Hoover","Herbert","1929-33"));
list.add(newPresident("Roosevelt","FranklinD.","1933-45"));
list.add(newPresident("Truman","Harry","1945-53"));
list.add(newPresident("Eisenhower","Dwight","1953-61"));
list.add(newPresident("Kennedy","JohnF.","1961-63"));
list.add(newPresident("Johnson","Lyndon","1963-69"));
list.add(newPresident("Nixon","Richard","1969-74"));
list.add(newPresident("Ford","Gerald","1974-77"));
list.add(newPresident("Carter","Jimmy","1977-81"));
list.add(newPresident("Reagan","Ronald","1981-89"));
list.add(newPresident("Bush","GeorgeH.W.","1989-93"));
list.add(newPresident("Clinton","WilliamJ.","1993-2001"));
list.add(newPresident("Bush","GeorgeW.","2001-present"));
list.add(newPresident("Washington","George","1789-97"));
list.add(newPresident("Adams","John","1797-1801"));
list.add(newPresident("Jefferson","Thomas","1801-09"));
list.add(newPresident("Madison","James","1809-17"));
list.add(newPresident("Monroe","James","1817-25"));
list.add(newPresident("Jackson","Andrew","1829-37"));
list.add(newPresident("VanBuren","Martin","1837-41"));
list.add(newPresident("Harrison","WilliamHenry","1841"));
list.add(newPresident("Tyler","John","1841-45"));
list.add(newPresident("Polk","James","1845-49"));
list.add(newPresident("Taylor","Zachary","1849-50"));
list.add(newPresident("Fillmore","Millard","1850-53"));
list.add(newPresident("Pierce","Franklin","1853-57"));
list.add(newPresident("Buchanan","James","1857"));
list.add(newPresident("Lincoln","Abraham","1861-65"));
list.add(newPresident("Johnson","Andrew","1865-69"));
list.add(newPresident("Grant","UlyssesS.","1869-77"));
list.add(newPresident("Hayes","RutherfordB.","1877-81"));
}
publicListgetData(){
returnlist;
}
}
President.java
publicclassPresident{
publicPresident(Stringlname,Stringfname,Stringterm){
lastName=lname;
firstName=fname;
this.term=term;
}
publicStringgetFirstName(){
returnfirstName;
}
publicvoidsetFirstName(StringfirstName){
this.firstName=firstName;
}
publicStringgetLastName(){
returnlastName;
}
publicvoidsetLastName(StringlastName){
this.lastName=lastName;
}
publicStringgetTerm(){
returnterm;
}
publicvoidsetTerm(Stringterm){
this.term=term;
}
privateStringlastName;
privateStringfirstName;
privateStringterm;
}
上面的Jsp页面是展现表格的,也表现了Display库最多见的用法:
index.jsp
<%@pagecontentType="text/html;charset=UTF-8"language="java"%>
<%@tagliburi="http://displaytag.sf.net/el"prefix="display"%>
<html>
<head>
<title>StrutsCookbook-Chapter4:DisplayTagExample</title>
<style>
.even{background-color:orange;}
.odd{background-color:yellow;}
</style>
</head>
<body>
<h2>DisplayTagExamples</h2>
<jsp:useBeanid="pagedData"class="PagedData"/>
<display:tableid="pres"name="${pagedData.data}"
sort="list"pagesize="10"defaultsort="3">
<display:caption>UnitedStatesPresidents</display:caption>
<display:setPropertyname="basic.show.header"value="true"/>
<display:columnproperty="firstName"title="FirstName"
sortable="true"/>
<display:columnproperty="lastName"title="LastName"
sortable="true"/>
<display:columnproperty="term"title="TermofOffice"
sortable="true"/>
</display:table>
</body>
</html>
在扫瞄器里翻开页面:
瞥见了吧,效果的确不错:)
要利用display标志库,必要在这里下载:
http://displaytag.sourceforge.net
把display.jar文件放到WEB-INF/lib中.
注重:
这里用到了EL,以是jstl.jar和standard.jar这两个库必要在lib中.
Display.jar依附2.0或以上的JakartaCommonsLang库,commons-lang-2.0.jar和JakartaCommonsCollections库,commons-collections.jar.
它们分离在:
http://jakarta.apache.org/commons和http://jakarta.apache.org/commons/collections/
下载,然后把对应的jar文件copy到WEB-INF/lib中.
复杂先容用法,实在也不必我多说,看看jsp文件也就基础懂了.
<display:tableid="pres"name="${pagedData.data}"
sort="list"pagesize="10"defaultsort="3">
id是今后用到时的变量.name是要展示的汇合数据.list暗示全部list被排序.pagesize暗示每页所要展现的数.defaultsort暗示最入手下手是按第几列排序的,注重这里是以1入手下手计数的.
<display:caption>UnitedStatesPresidents</display:caption>
isplay:caption标志两头的字符串是用来放到表格下面的题目.
<display:columnproperty="firstName"title="FirstName"
sortable="true"/>
display:column标志指定了每列的属性.
还要更多的利用办法,见Display标志库的Doc文档.
ruby里有这些工具吗?又要简单多少?我没有用过这两门语言,我估计在这些语言力没有很统一的这种标准,或者根本就没有提供。 |
|