Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > Java > webwork2.2.2 Value Stack
【标  题】:webwork2.2.2 Value Stack
【关键字】:webwork2.2.2,Value,Stack
【来  源】:http://www.blogjava.net/zkjbeyond/archive/2006/04/24/42902.html

webwork2.2.2 Value Stack

Your Ad Here Said another way, let's say I have a value stack that consists of a
model and an action as follows:

[ model, action ]
here's how the following ognl would resolve:
[0] - a CompoundRoot object that contains our stack, [model, action]

[1] - another CompoundRoot that contains only [action]

[0].toString() - calls toString() on the first object in the value stack (excluding the CompoundRoot) that supports the toString() method

[1].foo - call getFoo() on the first object in the value stack starting from [OS:action] and excluding the CompoundRoot that supports a getFoo() method

以上是webwork文档中谈到Value Stack部分.看了有些晦涩,我试验了下,与大家分享.(没看源代码)
Action:

public?class?HomeAction?implements?Action?{
????
private?String?name=?"propertyOfAction";
????
private?Person?person=null;
????
private?Collection?collection?=?new?ArrayList();
????
public?String?execute()?throws?Exception?{
????????collection.add(
new?Person("zkj"));
????????collection.add(
new?Person("yql"));
????????collection.add(person);
????????
return?SUCCESS;
????}

????
public?String?getName()?{
????????
return?name;
????}

????
public?Person?getPerson()?{
????????
return?person;
????}

????
public?Collection?getCollection()?{
????????
return?collection;
????}

????
public?void?setPerson(Person?person)?{
????????
this.person?=?person;
????}

}

在jsp页面中:

如果我们直接
<ww:property value="[0]"/>?? 输出com.founder.HomeAction@e3ffdf,com.opensymphony.xwork.DefaultTextProvider@d402dd]
<ww:property value="[1]"/>?? 输出

[com.opensymphony.xwork.DefaultTextProvider@d402dd]
一般我们在没有循环的情况下不用[0]? [1] 可以直接访问

<ww:property value="name"/>输出?
propertyOfAction

那么[0] [1] 有什么用呢,在循环中就体现出来了.

<ww:iterator?value="collection"?status="person">
????????????
<ww:if?test="#person.first?==?true">?
????????????????[0]?:
<ww:property?value="[0]"/></br>
????????????????[1]?:
<ww:property?value="[1]"/></br>
????????????????[2]?:
<ww:property?value="[2]"/></br>
????????????
</ww:if>
</ww:iterator>
[0] :[com.founder.Person@b3a5a0, com.founder.HomeAction@e3ffdf, com.opensymphony.xwork.DefaultTextProvider@d402dd]
[1] :[com.founder.HomeAction@e3ffdf, com.opensymphony.xwork.DefaultTextProvider@d402dd]
[2] :[com.opensymphony.xwork.DefaultTextProvider@d402dd]
输出以上代码,说明在一层循环中我们要访问[1]表示action对象.和没有循环的[0]对应.


总结:

假如你用webworkNOUI标签,对于Value Stack,一般你不要考虑[1] [0]之类的.记住一点
如果在循环中action的collection属性时体内,用[1]可以访问action对象和对应的属性.

对于多层循环或复杂用法,我只能告诉你,你的设计有问题?重构Model代码吧.


[Flash教程]ClearCase教程--开发人员加入ClearCase项目:【上一篇】
项目杂感:【下一篇】
【相关文章】
  • webwork2.2.2的dtd解析问题(感谢飞云小侠)
  • C和C++里面的lvalue 和 rvalue的释义
  • Debug Tutorial Part 2: The Stack
  • 有关 C++的 stack queue 的使用
  • 取得form里checkbox的value值
  • SHELL十三问之五:var=value?export 前后差在哪?
  • 收藏:堆(heap)和堆栈(stack)的区别
  • C++ 标准模板库(STL)编程示例 - 容器适配器Stack
  • Webwork2.2.2 重返Client Validation
  • interceptor和ognlvaluestack
  • 【随机文章】
  • 鬼武者3 十连斩高成功率心得
  • 利用GDI+分割图片,在图片上加字
  • J2ME之HelloMIDlet
  • Raize Components 3.0.10 (控件包)
  • AIX 0522错误
  • JSP和Servlet中的绝对路径和相对路径问题
  • 利用HTML优化加快网页速度
  • 两种自动检测USB设备的添加和移除的方法
  • C++最初的3个课件已经到了。
  • 爆笑笑话
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.