第二节课主要是讲GI的事件,这部分比较抽象,因此用图形来说明问题。
http://www.felixwoo.com/wp-content/uploads/attachments/200803/19_060908_event.jpg

GI之父Luke每周的培训讲座是这次来美国难得的收获,把每节课的总结发表出来和大家分享。第一节课主要内容是GI的Box模型,因为要跟整个团队分享,所以用英文写的,大家凑合着看吧。

1, What is GI?
The definition of GI on TIBCO's website is "TIBCO General Interface™ Builder is the award winning AJAX solution for rapidly building and easily deploying Rich Internet Applications (RIA), AJAX components and portlets that look and feel like desktop software." Actually, this definition focuses on what GI can do but not what GI is. Technically speaking, GI is a client-side server which also has the Model, View and Controller as the same as server application. The general server application generates data for client side, but GI generates the data and page for browser. In fact, the core of GI is a Page Server which takes charge of rendering data and view for web browser.

2, Outside-In & Inside-Out
Different web browsers have different understanding on the same HTML and CSS. Generally, there are two types of HTML box model explaining, one is Outside-In, another one is Inside-Out. For example, the code <span style="width:100;height:100;padding:10;border:10 solid"/> illustrate a box in the browser. In the Outside-In model, the real width and height are both 100, and the border and padding are painted inside the box. However, in the Inside-Out model, the real width and height of box are both 140. Because the Inside-Out model is document-centered, that is to say the content in the box possess the 100 width and height, and the padding and border are expanded outward by the content (See the picture below).

The Inside-Out model is friendly for content, but not easy for size controlling and not suitable for the web application. Therefore, GI chosen the Outside-In model. The problem is different browsers draw different boxes according to the same HTML code (e.g. IE6 is Outside-In, but IE7/8/Firefox are Inside-Out). So, what GI has to do is translating the box definition to make all the web browsers behave the same. For example, if you want to get a box with 100*100 dimension, 10px border and padding inside in Firefox. GI will generate <span style="width:60;height:60;border:10 solid; padding:10;"> for Firefox, and "width:100;height:100" for IE6.

http://www.felixwoo.com/wp-content/uploads/attachments/200803/19_060258_boxmodel.jpg

3, How is a GI box painted?
Every GI box model is extended from the object model which owns the basic property, such as id, name, etc. And the box model has some more properties which illustrate how the box looks like. Then, the GI will generate the HTML according to the box definition by executing paint method. Finally, the browser display the box on screen.
http://www.felixwoo.com/wp-content/uploads/attachments/200803/19_060358_boxmodel2.jpg

4, How does a GI box resize?
When the browser window size is changed, the outside parent block will notify the inside child block that “My size is changed, your space is also changed.” Then, the parent tell child how much space the child has. Finally, GI repaint the child according to the new size.

TIBCO AJAX大赛终于落下帷幕,由于我是公司内部员工,因此无缘和公司外的众多高手一绝高下,不过还是获得了大赛的特别奖。
另外我的参赛作品glickr已经发布在了http://www.glickr.cn ,英文版可以访问http://www.glickr.cn/#l=en_US ,也可以在欢迎界面上切换语言。虽然glickr是为大赛而生,不过我更希望把他做成一款产品,因此glickr还会持续更新。关于glickr的介绍可以浏览http://www.felixwoo.com/article.asp?id=295 和http://www.felixwoo.com/article.asp?id=292

非常荣幸的得到了GI之父Luke Birdeau对glickr的评价:

Felix,
I just got a chance to see your glickr application for the first time yesterday. It's great. I really like site concept (pictures/geography) and how you expressed it. Your execution is especially nice. I like the spacing, colors, usability, etc. Your source code is clean, well-documented and efficient.
I'm really impressed.
--Luke Birdeau

TIBCO用户体验组架构师Joel对glickr的评价:

Wow, Felix!
I'm very impressed! Very nice app. :) Congratulations, it is well-earned. I especially like the full-view mode of the photos. The left and right mouse clicks to navigate is nice...I like the mouse-over on the header triggering the full description overlay on the picture...that was a very excellent idea.
Are you planning to continue further devleopment on this? If so, I'd love to give some feedback on ideas for it.
--Joel

把证书发上来秀一下 [taste]
http://www.felixwoo.com/wp-content/uploads/attachments/200801/17_202558_ajax2.jpg

最近用TIBCO General Interface(GI)开发了一个mashup应用,整合了Google Map和Flickr,所以起名glickr。
glickr用法很简单,在地图上单击鼠标可以显示出当地的照片,也可以通过搜索关键字浏览各地的照片。每张照片都会在地图的相应经纬度坐标上显示出来。单击小的缩略图还可以放大显示。自动播放功能可以自动显示列表中的照片,并在地图上显示动画效果。

使用说明
1) 在地图上单击显示当地照片(可设定选择区域大小)
2) 搜索关键字
3) 自动播放照片列表(可调整播放速度)
4) 单击缩略图放大显示(大图模式下鼠标左键显示下一张,右键显示上一张)

访问glickrhttp://www.glickr.cn
欢迎大家积极反馈并提出宝贵建议。

http://www.felixwoo.com/wp-content/uploads/attachments/200711/22_080502_glickr1.jpg
http://www.felixwoo.com/wp-content/uploads/attachments/200711/22_080516_glickr2.jpg

http://www.felixwoo.com/wp-content/uploads/attachments/200709/22_075903_logo_power.gif
最近公司正在筹划AJAX国内挑战赛The Power of You,要求用TIBCO的GI(General Interface)开发一款AJAX的Web应用程序,大奖高达35,000人民币,相当具有诱惑力。做为全球会用GI的仅有的几位开发者之一(汗-_-!!不过我们老板都是这么介绍的),做为公司的一名有志青年,为了这35k的奖金,我难以抑制参赛的冲动。不过,相信民间也不乏GI的高手,希望大家踊跃参加,积极交流,这对于GI在中国的推广大有裨益。为了这次比赛,我们Team还准备在国内各大高校举办技术宣传活动和讲座,希望高校的同学们看到后积极与我联系。

比赛官方网站:http://www.tibco.com/contest/china/index.html
参赛时间:2007年9月10 -- 2007年12月31日
奖项:一等奖1名,35000 RMB;二等奖4名,8000 RBM;

另外,我很荣幸的成为了GI论坛中文板块的版主,希望大家踊跃踢馆。

http://power.tibco.com/forums/forum.jspa?forumID=124

以下是Michelle同学制作的GI介绍Flash,不知道GI的朋友可以先了解一下:

http://media.tibco.com/contest/gi_v1/tibco_gi_preso.html

The purpose of creating sustained messages is to provide totally loosely coupled architecture. In the case of sustained messages the UI components can be loaded asynchronously in any arbitrary order. As soon as a component that subscribes to a subject is loaded (first after a sustained message with the same subject is published) the event dispatcher will publish again the same message to the subscriber. Consider that this is a 1 to 1 publishing so that an already existing subscriber dose not receives same message multiple times. However, this pub sub mechanism differs from GI pub sub only in the persisting the messages. It is the responsibility of developer to unsubscribe an object or function from an event published by this object if it is not needed any more. Subscribing an object or function to a type of event multiple times causes that the function is executes multiple times if a message is published.

ThinkPage最新推出天气预报查询和网页插件功能,不仅可以在这里查询天气,还可轻松为您的博客添加天气预报功能。

地址:http://www.thinkpage.cn/weather/

ThinkPage插件有什么不一样:

  1. 全国及世界主要城市实时天气和5天内天气预报,数据每小时更新
  2. MSN、Yahoo、中央气象台等多数据源选择
  3. 自动识别访问者IP,显示相应城市天气
  4. 自动识别访问者浏览器语言,简体中文、繁体中文、英文多语言支持
  5. 丰富的主题和灵活的样式定制
  6. 精美的PNG天气图标,完美配合任何背景
  7. 应用AJAX技术,给您无刷新的全新体验
  8. 轻松嵌入博客和任何网站,让您的网页感知冷暖

阅读全文

这两天尝试使用ASP.NET AJAX Extensions给ThinkPage的PageRank查询增加了文本框自动提示功能。当用户在输入网站地址的文本框中输入的时候会自动弹出一个下拉菜单,显示最近查询过的网站,并不断根据输入文本的内容缩小范围。比如:当输入“w”的时候,会列出所有w开头的网址,当输入到“www.f”的时候,就只显示www.felixwoo.com了。当点击下拉菜单中的一个网址后,会自动完成文本框中的内容。整个过程和IE的地址栏效果类似。显示效果如图:
http://www.felixwoo.com/wp-content/uploads/attachments/200611/04_123834_autocomplete.jpg

这个功能是通过ASP.NET AJAX AutoCompleteExtender实现的,只需要几行代码即可搞定。
首先需要在页面上添加asp:AutoCompleteExtender标记,别忘了之前要有asp:ScriptManager的声明。

<asp:ScriptManager ID="ScriptManager" runat="server" />
<asp:AutoCompleteExtender ID="AutoCompleteExtender1" TargetControlID="searchtext"
runat="server" ServiceMethod="GetCompletionList"
ServicePath="~/SearchAutoComplete.asmx" MinimumPrefixLength="1" />

其中TargetControlID为输入网址的文本框的ID,ServicePath为得到网站列表的webservice地址,ServiceMethod即那个webservice中的具体方法,MinimumPrefixLength=1意思是当输入一个字符的时候即开始提示。

在SearchAutoComplete.asmx中要做的就是从数据库中返回最近查询过的网站,并通过prefixText参数来过滤出只以prefixText开头的网站,这样才能实现逐级提示的功能。SearchAutoComplete.asmx代码如下:

[WebMethod]
public string[] GetCompletionList(string prefixText, int count)
{
List<string> list = DataProvider.GetURLList();
foreach (string s in list)
{
if (s.StartsWith(prefixText))
{
list.Add(s);
}
}
return list.ToArray();
}

其中List<string> list是声明的了一个string的范型,这个是.net 2.0中新增的功能,避免了原来使用ArrayList带来的装箱和拆箱的性能消耗。DataProvider.GetURLList()从从数据库返回所有网站列表,返回类型自然也是List<string>。其他的代码都很简单,相信一看就明白了。

就短短的几行代码就可以实现如此有趣和实用的功能,不能不说ASP.NET AJAX为我们做了太多。

微软最近发布了ASP.NET AJAX 1.0的官方测试版本,最终版将在今年底发布,并与ASP.NET 2.0整合。这玩意原来叫Atlas,现在竟然彻头彻尾的变了,我想最郁闷的莫过于Dflying Chen了,他即将出版的《Atlas程序设计》看来前功尽弃了。感叹啊,做程序员和做小姐没什么区别,都是靠吃青春饭。等正式版出来以后再去更新ThinkPage吧,ThinkPage的开发告一段落,继续回到我的English Kingdom。

注:ASP.NET AJAX是微软进军跨平台网络功能领域的作品,用于异步JavaScript的网络开发,可以让开发人员开发出更具互动行动网络应用,提高用户个性化水平。ASP.NET AJAX 1.0的主要功能有:异步客户端到服务器网络、服务器端ScriptManager和ScriptManagerProxy控件、客户端Trace类、Timer控件、Selector控件、JavaScript认证等等。微软ASP.NET AJAX官方网站是http://ajax.asp.net/,在这里你可以找到程序下载、说明文档、演示视频、交流社区等资源。

这篇文章简要的介绍了通过使用Atlas UpdatePanel控件进行局部页面渲染的概念。如果你理解了什么是Atlas,你将从这篇文章中受益匪浅。

这篇文章包含了一个很简单的代码示例,教您如何使用UpdatePanel控件来局部渲染页面。使用UpdatePanel的主要优点有:
1、减少了数据页面更新导致的页面刷新次数
2、减少了页面更新传送的数据量(因为在数据回送postback的时候,并不是整个页面都需要完全重新渲染)
3、通过加快UI响应速度提高了用户使用体验。

下面这个例子展示了如何为应用程序增加UpdatePanel控件。
http://atlas.asp.net/docs/Walkthroughs/Samples/datepicker.aspx

从这个示例中我们可以看到,点击页面中心的大的日历整个页面都会刷新,而点击左上方的小日历选择某个日子,页面并不会刷新,而且反应非常迅速。这就是因为这个日历被UpdatePanel包裹了,所以具有了局部页面无刷新渲染的特性。

因此,为一个ASP.NET控件增加AJAX的无刷新效果非常的简单,只要把其放在UpdatePanel内就可以了。

示例源代码如下:

<%@ page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void ChosenDate_TextChanged(object sender, EventArgs e)
{
DateTime dt = new DateTime();
DateTime.TryParse(ChosenDate.Text, out dt);

CalendarPicker.SelectedDate = dt;
CalendarPicker.VisibleDate = dt;
}

protected void Close_Click(object sender, EventArgs e)
{
SetDateSelectionAndVisible();
}

protected void ShowDatePickerPopOut_Click(object sender, ImageClickEventArgs e)
{
DatePickerPopOut.Visible = !DatePickerPopOut.Visible;

// corrdinates are relative to the control, so we need to get the control's
// position too
int h = (int)ShowDatePickerPopOut.Height.Value;
SetDatePickerPopOutStyle(e.X + h, e.Y);
}

protected void CalendarPicker_SelectionChanged(object sender, EventArgs e)
{
SetDateSelectionAndVisible();
}

private void SetDateSelectionAndVisible()
{
ChosenDate.Text = CalendarPicker.SelectedDate.ToShortDateString();
DatePickerPopOut.Visible = false;
}

private void SetDatePickerPopOutStyle(int x, int y)
{
DatePickerPopOut.CssClass = "PopUpShow";
DatePickerPopOut.Attributes.Add("style", "top:" + x + "px;left:" + y + "px;");
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<style type="text/css">

.PopUpShow
{
background-color:lightblue;
position:absolute;
visibility:show;
width:150px;
height:150px;
z-index:1;
border: solid 2px black;
}

</style>
</head>
<body>
<form id="form1" runat="server">
<atlas:scriptmanager id="ScriptManager" runat="server"
enablepartialrendering="true" />
<h4>With an UpdatePanel</h4>
<!-- This section of the page is wrapped by an UpdatePanel. -->
<atlas:updatepanel id="up" runat="server" mode="Conditional"
rendermode="Inline">
<triggers>
<atlas:controleventtrigger controlid="CalendarPicker"
eventname="SelectionChanged" />
</triggers>
<contenttemplate>
<asp:textbox runat="server" id="ChosenDate"
ontextchanged="ChosenDate_TextChanged" autopostback="true" />
</contenttemplate>
</atlas:updatepanel>
<span style="position: relative;">
<asp:imagebutton runat="server" id="ShowDatePickerPopOut"
onclick="ShowDatePickerPopOut_Click" imageurl="~/images/calendar.gif"
height="20px" width="20px" />
<!-- This section is also wrapped by an UpdatePanel. -->
<atlas:updatepanel runat="server" id="up1" mode="Conditional"
rendermode="inline">
<triggers>
<atlas:controleventtrigger controlid="ShowDatePickerPopOut"
eventname="Click" />
</triggers>
<contenttemplate>
<asp:panel runat="server" id="DatePickerPopOut" visible="false">
<asp:calendar id="CalendarPicker" runat="server" backcolor="White"
bordercolor="White" borderwidth="1px" font-names="Verdana"
font-size="6pt" forecolor="Black" height="139px"
nextprevformat="FullMonth" width="100px"
onselectionchanged="CalendarPicker_SelectionChanged">
<selecteddaystyle backcolor="#333399" forecolor="White" />
<todaydaystyle backcolor="#CCCCCC" />
<othermonthdaystyle forecolor="#999999" />
<nextprevstyle font-bold="True" font-size="6pt"
forecolor="#333333" verticalalign="Bottom" />
<dayheaderstyle font-bold="True" font-size="6pt" />
<titlestyle backcolor="White" bordercolor="Black" borderwidth="4px"
font-bold="True" font-size="8pt" forecolor="#333399" />
</asp:calendar>
<br />
<asp:linkbutton id="CloseDatePickerPopOut" runat="server"
font-names="Tahoma" font-size="small" onclick="Close_Click"
tooltip="Close Pop out">
Close
</asp:linkbutton>
</asp:panel>
</contenttemplate>
</atlas:updatepanel>
</span>
<hr />
<br />
<!-- The remainder of the page does not have an UpdatePanel, so it cannot
participate in the benefits of partial page rendering on postbacks. -->
<div style="text-align: center;">
<h4>Without an UpdatePanel</h4>
<asp:calendar id="Calendar1" runat="server"></asp:calendar>
</div>
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor
sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed
diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et
ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem
ipsum dolor sit amet.
</p>
<p>
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie
consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et
accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit
augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet,
consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt
ut laoreet dolore magna aliquam erat volutpat.
</p>
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor
sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed
diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et
ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem
ipsum dolor sit amet.
</p>
<p>
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie
consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et
accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit
augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet,
consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt
ut laoreet dolore magna aliquam erat volutpat.
</p>
</form>
</body>
</html>

京ICP备05053527号
经过26次查询历时0.424秒终于生成了此页面
Powered by WordPress & Designed by Felix © 2012