Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Jute Powerful Forum  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Jute Engine begins to support ViewState
rainman

阿熊

元老


发贴: 5644
积分: 454
于 2003-07-18 06:36 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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保存浏览状态。一切都是为了网站的粘性。


rainman edited on 2003-07-18 18:27


作者 Re:Jute Engine begins to support ViewState [Re:rainman]
abc123





发贴: 81
积分: 20
于 2003-07-18 18:16 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Cool~
Support!

Wink



作者 Re:Jute Engine begins to support ViewState [Re:abc123]
morchory

Neo

Jute Pro User


发贴: 150
积分: 60
于 2003-07-21 01:36 user profilesend a private message to usersend email to morchorysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
abc123 wrote:
Cool~
Support!

Wink


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




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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