GWT版——图书管理程序开发完工 GWT version - the completion of the development of library management procedures
07月13th, 2006 — Dreamer 07月13 th, 2006 - Dreamer用GWT( Google -Web-Toolkit)开发的图书管理系统终于完工了。 With GWT (Google-Web-Toolkit) development of the library management system was finally completed. 总体评价: Overall rating:
1.界面不美观,简直是很丑陋。 1. Bumei Guan interface, it is very ugly. 因为个人比较懒,而且对艺术一窍不通,再加上是从头开始学习这个东西,所以就比较专注于功能的实现,而不是界面了。 Because of personal Bijiao Lan, but also to know nothing about art, coupled with the start studying this thing, is more focused on the achievement of functional, rather than the interface.
2.功能少。 2. Function less. 只有公告,用户信息显示,添加和删除,借还书功能。 Only notice, the user information, add and delete, to make use of the function. 而且没有实现分页功能,这个最失败,今天检查作业的时候老师居然让我一直添加信息,所以一下就把我的这个漏洞给暴露了,哎。 And did not realize paging features, the most failed, inspection operations today when the teacher has even let me add information, so I put some of this loophole exposed to, hey. 关键是添加分页功能有点麻烦,需要自己编写几个控件,又要把函数编写得天衣无缝,现在时间又紧,所以只好作罢。 The key is to add a little trouble paging function, the need to control their own preparation of a few, prepared to function in a seamless, time-tight, so had to give up.
3.模块化还不错。 3. Modular pretty good. 这次自认为在数据隐藏和模块化部分做的还行。 The hidden in the data since that part of modular and also to do. 相关的类都放在了一起,而且有相同功能的类都让我提取出来建立了父类,重构真是无处不在阿。 Related categories are placed together, and have the same type of function I have extracted a father of categories, reconstruction in Afghanistan is everywhere. 正如《重构》中说的那样:“花一点时间重构是值得的”,现在代码优雅多了。 As the "reconstruction" that stated: "spend some time reconstruction is" now more elegant code.
GWT最大的好处就是用JAVA编码,不过个人认为其中的控件布局还挺简单,只要你熟悉JAVA,做几个练习就能掌握了,个人建议把那个GWT自带的展示Widget 的例子敲一遍。 GWT the biggest benefit is to use JAVA coding, but personally think that one's kinda simple layout of the controls, as long as you are familiar with JAVA, do a few exercises can have a personal proposal to the display that comes with GWT Widget example knock again. 个人认为最不好懂的就是GWT中的异步传输,就是和server端交互的那一段,虽然GWT的文档中有说明,不过理解起来还是有点困难,大家最好看一下GWT自带的DynaTable例子,里面虽然没有连接数据库,但是给出了如何与服务器端交互。 Personally think that the worst is to understand the GWT in asynchronous transfer, and server-side interactive section, although GWT note in the document, but is still a bit difficult to understand, we look at the best GWT comes with the DynaTable example Inside although not connected to the database, but given how to interact with the server-side. 我在这里以DynaTable(在Gwt中的sample文件夹里)再说明一下步骤: I am here to DynaTable (Gwt in the sample folder) explain once again the steps:
1.在client包里建立一个接口:SchoolCalendarService,它必须继承com.google.gwt.user.client.rpc.RemoteService;,其中声明一个方法: 1. Bag in the establishment of a client interface: SchoolCalendarService, it must inherit com.google.gwt.user.client.rpc.RemoteService;, including a statement:
这里的Person是一个类名,保存关于Person的信息,因为这个方法返回一个对象数组,所以要这样声明。 Here's Person is a class name, save on the Person of the information, because this method returns an array of objects, so this statement.
2.再在client中建立一个接口:SchoolCalendarServiceAsync,不用从任何类继承,里面也有一个方法: 2. Again in the establishment of a client interface: SchoolCalendarServiceAsync, not from any type of succession, there is also a method:
它和上面建立的SchoolCalendarService只有两个地方不同: Above it and the establishment of the SchoolCalendarService only two different places:
1.返回类型是void,这点要记住。 1. Return type is void, it points to remember.
2.多了一个参数:AsyncCallback 。 2. One more parameter: AsyncCallback. 这个是用来异步传输的,这也是返回类型是void的原因。 This is used to asynchronous transfer, which is also the return type is void of reason.
3.在Server端建立一个类: 3. Server-establishment of a category:
SchoolCalendarService
它必须执行第一步声明的SchoolCalendarService,并实现它的方法。 It must first step in the implementation of the Declaration SchoolCalendarService, and the method of achieving it. 这里有一个问题:当我从数据库中读取数据并传给对象数组的时候,如果直接对这个对象数组操作,会出现错误。 Here's a question: When I read data from the database and pass an array of targets, if this object directly on the array operation, there will be mistakes. 我不知道怎么回事。 I do not know how the case. 不过可以先声明一个ArrayList,然后没读取一条记录,就声明一个对象,赋值之后再添加到ArrayList中,最后再声明一个对象数组,操作后再传回去,象这样: But the statement could be a ArrayList, and then did not read a single record, a statement on the subject, added after the assignment Add ArrayList, the final statement to an object array, operating after-back, like this:
…………
while(rs.next()){ while (rs.next ()) (
BookInfo temp = new BookInfo(); BookInfo temp = new BookInfo ();
temp.setTitle(rs.getString("title")); temp.setTitle (rs.getString ( "title"));
temp.setAuthor(rs.getString("author")); temp.setAuthor (rs.getString ( "author"));
temp.setIndex(rs.getString("index")); temp.setIndex (rs.getString ( "index"));
temp.setPlace(rs.getString("place")); temp.setPlace (rs.getString ( "place"));
temp.setPrint(rs.getString("print")); temp.setPrint (rs.getString ( "print"));
temp.setPublish(rs.getString("publish")); temp.setPublish (rs.getString ( "publish"));
content.add(temp); content.add (temp);
} )
…………
BookInfo[] results = new BookInfo[content.size()]; BookInfo [] results = new BookInfo [content.size ()];
for(int i=0;i<content.size();i ) for (int i = 0; i <content.size (); i )
results[i] = (BookInfo)content.get(i); results [i] = (BookInfo) content.get (i);
return results; return results;
4.最后在客户端获取数据的时候,这样做(这个也可以从文档中看到): 4. Finally, the client access to data, to do so (this can also be seen from the document):
ServiceDefTarget target = (ServiceDefTarget)bulService; ServiceDefTarget target = (ServiceDefTarget) bulService;
target.setServiceEntryPoint("/bulletin"); target.setServiceEntryPoint ( "/ bulletin");
AsyncCallback callback = new AsyncCallback(){ AsyncCallback callback = new AsyncCallback () (
public void onSuccess(Object result){ public void onSuccess (Object result) (
results = (PublicInfo[])result; results = (PublicInfo []) result;
……
} )
public void onFailure(Throwable caught){ public void onFailure (Throwable caught) (
…………
} )
}; );
bulService.getBulletin(callback); bulService.getBulletin (callback);
这里我只想着重说明红色部分,其它的说明文档中有详细说明。 Here, I just want to focus on the red part of other documentation in detail.
target.setServiceEntryPoint("/bulletin"); target.setServiceEntryPoint ( "/ bulletin");
这一点很重要,你设置这个的时候,必须在程序的xml文件中同时设置servlet,这样写: This is important, you set up this time, the procedures must be in the xml document also set servlet, written like this:
必须要这样做,不然就会出错! Must do so, will not go wrong! ! !
results = (PublicInfo[])result; results = (PublicInfo []) result;
由于传回来的只是一个对象,所以你必须使用强制类型转换才能操作。 As the back-just an object, so you must use the mandatory conversion to operate.
以上就是与服务器端交互的说明。 That interaction with the server side of the note.
再来说一下我自己的程序。 Again, my own procedures. 我的程序最外层是一个DeckPanel,它有一个z坐标,所以它每次都显示其中的一个子页面,我就是用这个来做页面切换。 I procedures for the outer layer is a DeckPanel, it has a z coordinates, so it show every time one of the sub-pages, I use this to do is to switch pages. 后台用了ACCESS数据库,用Eclipse编码,使用JDBC-ODBC连接数据库,不过如果要连接数据库比须要先配置ODBC。 ACCESS database with the background, using Eclipse coding, the use of JDBC-ODBC link database, but if want to connect to the database than the first allocation of ODBC. 其它的东西我就不多说了。 Other things I will not say more. 如果有谁需要源代码的话,可以给我留言,留下E-Mail,我可以给你传过去。 If anyone needs the source code, it can give me messages, leaving E-Mail, I can give you-the past.
更新: 这个东西是我好久前做的,当时GWT还是beta,而且版本很低,现在估计已经有了很大改进,所以我这个东西早就是老古董了,代码我好像也丢了,就不发送了,抱歉 。 Update: This is what I do for a long time ago, when the GWT or beta, version and low, now estimated to have greatly improved, so I have this thing is Laogu Dong, the code I seem to be lost, not sent, sorry .
本文链接: http://www.zhuoqun.net/html/y2006/150.html 转载请注明出处,谢谢。 This link: http://www.zhuoqun.net/html/y2006/150.html reprint please reference, thank you.
TrackBack引用地址: http://www.zhuoqun.net/html/y2006/150.html/trackback TrackBack used Address: http://www.zhuoqun.net/html/y2006/150.html/trackback



谢谢,能否给我份源码? Thank you, can you give me the source »
julycoolboy@gmail.com julycoolboy@gmail.com
谢谢,能否给我份源码? Thank you, can you give me the source »
gaolei_1024@163.com gaolei_1024@163.com
能否发份源码,学习下! Can the source of learning under!
邮箱:yangbaobao8827@163.com E-mail: yangbaobao8827@163.com
谢谢拜读一下能否给我份源码? Thank you, I can read about the source » jiujiu_77@163.com jiujiu_77@163.com
谢谢!能否给份源码学习一下!polkmn0987@163.com Thank you! Able to learn about the source! Polkmn0987@163.com
刚学习GWT,能否发一份源码学习,谢谢! Just learning GWT, whether a source of learning, thank you! ! ! ! !
刚忘了写邮箱了,zyang-093@163.com 谢谢 Just forgot to write the mail, zyang-093@163.com Thank you
麻烦你给我发一份,谢谢。 Trouble you for giving me a Thank you. Pine_850827@hotmail.com
谢谢,学习GWT中,一直没找到数据库的好方法,麻烦给一份代码吧。 Thank you, learning GWT, the database has not found a good way, the trouble to a bar code.
huangh0621@gmail.com huangh0621@gmail.com
请给我发一份源码,谢谢! Please give me a source, thank you!
allenchue#gmail.com allenchue # gmail.com
请发份源代码给我好吗, 我也在学习中, 先谢了. znfsouth@gmail.com Please send me the source code to the good, I also study, the xian XIE. Znfsouth@gmail.com
急需连数据库的源码,如能提供,非常感谢!!! Even the much-needed source database, if they can provide, very grateful!
muou55555@163.com muou55555@163.com
真的很谢谢……. Thank you, really…….
我们也正在用GWT开发,发份源码一起讨论下哈,谢谢 We are also using GWT development, a source in Kazakhstan under discussion, thank you
zhanglilei326@gmail.com zhanglilei326@gmail.com
汗~~怎么这么多要源码的? Khan ~ ~ how so many to be the source » [eek]
麻烦这位大哥给小弟传一份源码! email: saint112403@sina.com不胜感激!!![tea] The trouble-a big brother to Xiaodi source! Email: saint112403@sina.com be grateful!!! [Tea]
给我发份代码哈~! Give me the code of Kazakhstan ~!
33790310@qq.com 33790310@qq.com
请发一份源码给我学习学习。 Please give me a source learning learning.
chunlinyao {at] gmail.com chunlinyao (at] gmail.com
这位大哥,能否发给小弟一分可以直接导入eclipse并运行的工程!小弟现在还是个菜鸟,恳求您的帮助,非常感谢! The eldest brother, be distributed to Xiaodi one can directly import eclipse and run the project! Xiaodi is still a rookie, ask your help, very grateful!
email: saint112403@sina.com email: saint112403@sina.com
谢谢,我也需要一份。 Thank you, I have a need. 顺便问一下,操作数据库的类必须放到client包下吗? Shun Bianwen the operation of the database category client package must be put under it » 是否可以放到server包下? Whether the package can be put under the server »
xzgf2004@gmail.com xzgf2004@gmail.com
请给我发一份源码,谢谢! Please give me a source, thank you!
tim5305@gmail.com tim5305@gmail.com
不好意思, 在我运行这个程序的时候, 当我登入图书馆。 I am sorry, I run this procedure, when I log in to the Library. 。 . 。 . 它说 It said
[ERROR] Uncaught exception escaped [ERROR] Uncaught exception escaped
java.lang.ClassCastException: com.google.gwt.user.client.ui.DockPanel java.lang.ClassCastException: com.google.gwt.user.client.ui.DockPanel
问题应该在这一句“((DeckPanel)panel.getParent().getParent().getParent().getParent()).add(user)“ In this issue should be a "((DeckPanel) panel.getParent (). GetParent (). GetParent (). GetParent ()). Add (user)"
我想请教一下这是什么问题, I would like to ask the question of what it is,
我怎样才能做到切换业面 How can I switch to the surface
to tim:不好意思,GWT我只是用来做了一次大作业,现在已经差不多全部忘记完了,而且当时我使用的是某个版本的beta版。 to tim: I am sorry, GWT I just used to do a major operation, is now almost entirely forgotten the end, and then I use a version of a beta version. 所以我也不知道它为什么不能运行了,抱歉了 So I do not know why it can not run, the sorry
要源码? To source » 直接去http://code.google.com/webtoolkit/ Directly to http://code.google.com/webtoolkit/
请教这位好心大哥一个问题,帮我看看这是个什么错误? The eldest brother ask a question of good intentions, to help me see what this is a mistake »
[ERROR] Unable to instantiate 'com.dreamer.server.BulletinServiceImpl' [ERROR] Unable to instantiate 'com.dreamer.server.BulletinServiceImpl'
java.lang.ClassNotFoundException: com.dreamer.server.BulletinServiceImpl java.lang.ClassNotFoundException: com.dreamer.server.BulletinServiceImpl
在访问服务器端类的时候总有错误,是什么原因? During his visit when the server-side type of mistakes, what are the reasons »
to monster:抱歉。 to monster: Sorry. GWT我只是用来做了一次大作业,现在已经差不多全部忘记完了,所以也不清楚错误状况了,可能是GWT版本更新了 GWT I just used to do a major operation, is now almost entirely forgotten the end, so it was not clear error, and may be updated version of GWT
我非常需要发个给我谢谢大虾““““““““““邮箱:ericjohns1984@sina.com I very much need of a prawn """""""""" Thank you for giving me E-mail: ericjohns1984@sina.com
我也想要麻烦也发一份给我吧谢谢啦:) I also want to trouble also made a啦Thank you, to me:)
renyun2551@sohu.com renyun2551@sohu.com
我在用GWT做一个后台工具, 在入门的阶段, 能发我一份源码参考吗? I used to do a background GWT tools, in the introductory stage, I can be a source of reference? » 谢谢 Thanks
我的email是:leizhenheng@yahoo.com.cn My email is: leizhenheng@yahoo.com.cn
tsmood@gmail.com tsmood@gmail.com
非常感谢! Thank you very much!
给我一份,谢谢~ Give me a Thank you, ~
li_hy2004@163.com li_hy2004@163.com
我也刚接触gwt,找了个例子稍改了点弄到eclipse里面,报错] Deferred binding failed for 'whut.cs.ll.Test.client.MyInterface'; expect subsequent failures,查了好久实是不知道原因,望指点啊! I also Gangjie Chu gwt, for example a slightly changed the point to get inside eclipse, the error] Deferred binding failed for 'whut.cs.ll.Test.client.MyInterface'; expect subsequent failures, investigation It is a long time do not know why, looking guidance ah!
gwt.xml: gwt.xml:
<module>
<!– Inherit the core Web Toolkit stuff. –> <! - Inherit the core Web Toolkit stuff. ->
<inherits name='com.google.gwt.user.User'/> <inherits name='com.google.gwt.user.User'/>
<!– Specify the app entry point class. –> <! - Specify the app entry point class. ->
<entry-point class='whut.cs.ll.Test.client.myAjax'/> <entry-point class='whut.cs.ll.Test.client.myAjax'/>
<servlet path='/myAjax' class='whut.cs.ll.Test.server.MyInterfaceImpl'/> <servlet path='/myAjax' class='whut.cs.ll.Test.server.MyInterfaceImpl'/>
</module> </ module>
代码发不上来啊,郁闷死了 Of the code and could not, ah, depressing dead
求求你给我发个代码吧, I pray you to seek a code of the bar,
leoglee@gmail.com leoglee@gmail.com
我也想拥有一个自己的代码, 请批我一个把[smile] I would also like to have its own code, to grant me a [smile]
麻烦给我发一份代码,正在做一个连接数据库的非常需要谢谢! Send me a trouble code, is doing a great need to connect the database Thank you! ! ! ! !
chaoxxin@gmail.com chaoxxin@gmail.com
你好给我也传一份行不? Hello to a line-I do not » 谢谢啦:) Thank you啦:)
coderchang@yahoo.com.cn coderchang@yahoo.com.cn
可以给我发吗我的邮箱是wangkobe214@163.com I can give you my mailbox, is wangkobe214@163.com
谢谢我也在学习使用gwt Thank you, I am also learning to use gwt
刚学习GWT,能否发一份源码学习,邮箱fuzhousea@163.com。 Just learning GWT, whether a source of learning, E-mail fuzhousea@163.com. 谢谢! Thanks! ! ! ! !