星期一 六月 23, 2008
Is there really a Demo God?
I used to think this was a joke, but now I believe there must be one. Last week at Manila, I needed to do some demos for the JSF and AJAX session, which required Glassfish sever. Because my laptop is falling apart, I borrowed one and took it to Manila with my own laptop. I tested all the demos on both machines right before my session and everything worked fine. But...., when I got on the stage, it really caught me on surprise that the Glassfish failed to start, I tried the other laptop immediately, and guess what? Glassfish failed on the other laptop too! Glassfish failed on two machines at the same time? It is beyond the "Bad luck" could explain. And when I finally finish the session and got back to the speakers' room, and tried Glassfish on the borrowed laptop, it started with NO PROBLEM! And there is more, my own laptop can launch Glassfish with no problem as well now, but between now and then I did not touch it at all! Based on my unexplainable experience, I warn you that there is really a Demo God out there! Don't fool around with thy!
Posted at 12:03下午 六月 23, 2008 by Michael Li in 旅途见闻 | Comments[0]
星期二 十二月 04, 2007
NetBeans 6.0正式版发布
NetBeans 6.0正式发布了!正在下载ing...,囊括版(包含Java IDE,C/C++ IDE, Ruby IDE,UML,Mobility,SOA以及Apache Tomcat 6和Glassfish V2)总共才167.5M。
用过的IDE也有不少了,第一次这么期待正式版的发布。还记得两年前用的NetBeans 4.1, 真不敢相信NetBeans能在短短的两年间有如此翻天复地的变化!
Posted at 10:43上午 十二月 04, 2007 by Michael Li in Java | Comments[0]
星期一 十一月 19, 2007
DWR演示脚本 (AJAX技术及架构演讲续4)
DWR使客户端通过JavaScript调用Server端的Java对象。我脑海里闪过一个典型应用就是不再需要做两套HTML表单的验证(server端和JavaScript客户端)了,通过DWR,JavaScript可以直接调用Server端的java对象了!
演示准备
演示脚本
|
<servlet> |
|
package server; public class DataProvider { |
|
<dwr> |
|
<%@page contentType="text/html"%> <html>
<body> </html> |
Posted at 07:07下午 十一月 19, 2007 by Michael Li in Web 2.0 | Comments[0]
Google Web Toolkit演示脚本 (AJAX技术及架构演讲续3)
演示准备
演示脚本
|
public List getDemoData(String prefix); |
|
public void getDemoData(String prefix, AsyncCallback callback); |
|
public List getDemoData(String prefix) { |
|
private FlowPanel contentPanel = new FlowPanel();
final AsyncCallback linksCallback = new AsyncCallback() { public void
onSuccess(Object result) {
List resultList = (List) result;
String resultStr = resultList.toString();
contentPanel.clear();
contentPanel.add(new HTML(resultStr)); } public void
onFailure(Throwable caught) { }
};
public GWTDataServiceAsync getService() { GWTDataServiceAsync
service = (GWTDataServiceAsync) GWT.create(GWTDataService.class); ServiceDefTarget
endPoint = (ServiceDefTarget) service; String serviceURL =
GWT.getModuleBaseURL() + "gwtdataservice"; endPoint.setServiceEntryPoint(serviceURL); return service;
}
public void onModuleLoad() { HTML header = new
HTML("<h1>Programming Languages:</h1>"); final TextBox textBox
= new TextBox();
textBox.addKeyboardListener(new KeyboardListenerAdapter() {
public void onKeyUp(Widget sender, char arg1, int arg2) {
getService().getDemoData(textBox.getText(), linksCallback);
} });
RootPanel.get().add(header); RootPanel.get().add(textBox);
contentPanel.setWidth("400px");
RootPanel.get().add(contentPanel); } |
Posted at 06:17下午 十一月 19, 2007 by Michael Li in Web 2.0 | Comments[0]
星期四 十一月 15, 2007
Wicket演示脚本 (AJAX技术及架构演讲续2)
演示准备
演示脚本
|
<form wicket:id="form"> |
|
public Home() { Form form =
new Form("form"); add(form); final
AutoCompleteTextField field = new AutoCompleteTextField("prefix",
new Model("")) {
protected Iterator getChoices(String input) { List<String>
result = DemoDataProvider.getDemoData(input);
return result.iterator(); } };
form.add(field); final Label
label = new Label("terms", field.getModel());
label.setOutputMarkupId(true);
form.add(label);
field.add(new AjaxFormSubmitBehavior(form, "onchange") {
protected void onSubmit(AjaxRequestTarget target) {
target.addComponent(label); } }); } |

Posted at 07:42下午 十一月 15, 2007 by Michael Li in Web 2.0 | Comments[0]
DynaFaces演示脚本 (AJAX技术及架构演讲续1)
离上海Sun技术日都快三个礼拜了,答应把演示材料陆续贴出的,可期间连续出差,一直没动。现刚从日本回来,总算有时间能开始兑现我的诺言了。好,废话少说,埋头干活。
DynaFaces演示
演示准备工作
1.
下载和安装NetBeans
6.0 Beta 2。NetBeans 6.0现在已进入Beta 2,很快汉化版就会随着正式版本推出。
演示脚本
1. 启动NetBeans。“
2. File” -> “New Project”。
3. 在“New Project”对话框,左侧选“Web”,右侧选“Web Application”,然后“Next”。
4. 在“New Web Application”对话框,“Project Name”=DyanFacesDemo,“Server“=”GlassFish V2“然后“Next”。
5. 在“Frameworks”对话框,选择“Visual Web JavaServer Faces”,然后“Finish”。
6. 把Ajax_DemoData项目加到DynaFacesDemo的库中去,因为会用到它的类。
a. 右键“DynaFacesDemo”项目,在跳出窗口选择“Properties”
b. 在“Project Properties”窗口。左面选择“Libraries”;右面点击“Add Project...”,找到 Ajax_DemoData所在目录,点击“Add Project JAR File”。
c. 点击“Ok”关闭“Project Properties”对话框。
7. 在项目中加入DynaFaces面板组件。加入面板组件后就可以以托拽的方式使用DynaFaces的组件了。
a. 展开“DynaFacesDemo”项目
b. 右键“Component Libraries”目录,选择“Add Component Library...”
c. 在“Add
Component Library”对话框,选择“Dynamic Faces
Components(0.2)”,点击“Add Component Library”.
d. 注意“Dynamic
Faces”出现在屏幕右侧的组件面板的上方。打开它,可看到“Ajax Transaction”和“Ajax Zone”两个组件。
8. 从右面组件面板里拖入下列组件,如图所示
a. Basic
-> Label,并把显示文字改成”Programming Languages“
b. Basic
-> TextField
c. Layout
-> Layout Panel,调整框的大小
d. ”Dynamic
Faces“ -> “Ajax Transaction”,至页面空白处,这是个不显示的组件。

9. 切换到Java显示,找到prerender()方法,加入以下程序
|
@Override |
10. NetBeans这时会报错,因为fillContent()没有定义。按下列程序加入fillContent()的定义
|
private
void fillContent() { |
11. 接下来要通过DynaFaces加入AJAX的后台交互
a. 回到页面的”Design“窗口,选中”textField1“,在textField1的属性窗口内找到”onKeyUp“(在javaScript分类里),加入以下javaScript程序
|
DynaFaces.Tx.fire("ajaxTransaction1", "textField1") |
b. 右键”textField1“,选择”Configure Ajax Transaction…“。在跳出窗口里将”Send Input“的值改为”Yes“,并”OK“。
c. 右键”layoutPanel1“,选择”Configure Ajax Transaction…“。在跳出窗口里将”Re-Render“的值改为”Yes“,并”OK“。
12. 编程完毕,右键项目选择”Run“ ,NetBeans会编辑项目并部署到Glassfish服务器上,然后打开浏览器窗口显示运用,如下图

Posted at 06:49下午 十一月 15, 2007 by Michael Li in Web 2.0 | Comments[1]