Topic: Jute Engine begins to support ViewState

  Print this page

1.Jute Engine begins to support ViewState Copy to clipboard
Posted by: rainman
Posted on: 2003-07-18 06:36

ASP.Net 框架里有一个用html保存用户浏览状态的ViewState功能。
如下面的代码:

ViewStateForm.aspx


<%@ Page Language="VB" %>
<script runat="server">
  Sub btnSubmit_Click(Sender As Object, E As EventArgs)
    lblSentence.Text = txtName.Text & " selected " _
      & ddlColor.SelectedItem.Text
  End Sub
</script>

<html>
<head>
<title>ASP.NET Viewstate Form Sample #2</title>
</head>
<body bgcolor="#FFFFFF">

<form id="frmViewState" action="form1.aspx"
  method="post" runat="server">

  Enter Your Name:
  <asp:TextBox id="txtName" runat="server" />

  Pick a Color:
  <asp:DropDownList id="ddlColor" runat="server">
    <asp:ListItem>Red</asp:ListItem>
    <asp:ListItem>Orange</asp:ListItem>
    <asp:ListItem>Yellow</asp:ListItem>
    <asp:ListItem>Green</asp:ListItem>
    <asp:ListItem>Blue</asp:ListItem>
    <asp:ListItem>Indigo</asp:ListItem>
    <asp:ListItem>Violet</asp:ListItem>
  </asp:DropDownList>

  <asp:button id="btnSubmit" text="Submit"
    onClick="btnSubmit_Click" runat="server" />

</form>

<asp:label id="lblSentence" runat="server" />

</body>
</html>



如果用户的选择不符合业务逻辑,你需要重新返回表单,让用户重新选择,这时候表单上当然要预置用户上一次的输入。ASP.Net的ViewState功能不需要程序员编写额外的编码,而能透明的处理。这能提高效率增加网站的友好度。这对一个大表单拆成多个表单多次提交也是很方便的。比如填写好了第一个表单后,提交,第二个表单能自动保存第一个表单里提交的数据。

在这里,就不多说明ASP.Net是如何实现ViewState了,大家有兴趣可以自己去找资料。

如果要在Java Servlet/JSP里实现相同的功能,一般都需要用UI components这种方法来写表单。 用JSP Tag,JSF (Java Server Face: see also http://www.cjsdn.com/post/view?bid=8&id=32671&sty=3&keywords=viewstate 有一说明),Jakarta Tapestry 或 ECHO (see also http://www.cjsdn.com/post/search?bid=0&mode=or&age=0&limit=20&username=&words=Tapestry+Echo&pge=1&action=Search#result )是比较容易实现的,在Struts框架中应该也有办法咯。

Jute中的UI是基于模板的,在模板中可以使用JavaBean技术,目前已用比较简单的方式实现了通过HTML保存浏览状态。一切都是为了网站的粘性。

2.Re:Jute Engine begins to support ViewState [Re: rainman] Copy to clipboard
Posted by: abc123
Posted on: 2003-07-18 18:16

Cool~
Support!

Wink

3.Re:Jute Engine begins to support ViewState [Re: abc123] Copy to clipboard
Posted by: morchory
Posted on: 2003-07-21 01:36

abc123 wrote:
Cool~
Support!

Wink


看不懂是啥功能 .................
可以說白一點嗎 ...


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923