游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1636|回复: 0

复杂的webwork+hibernate的iterator问题:wxh zt

[复制链接]

1367

主题

1993

帖子

2118

积分

金牌会员

Rank: 6Rank: 6

积分
2118
发表于 2005-8-8 19:31:00 | 显示全部楼层 |阅读模式
在业务逻辑里,代码是这样

         Query query = session.createQuery("select p,pp,pc,pac from Product as p, ProductPrice as pp, ProductContent as pc,ProductAndCategory as pac where p.productId = :productId and pp.productId=:productId and pc.productId=:productId and pac.productId = :productId");
         query.setParameter("productId",productId);


         List result = query.list();
         
         Query query1 = session.createQuery("select pa.attributeValue from ProductAttribute pa where pa.attributeName = 'picName' and pa.productId = :productId");
         query1.setParameter("productId",productId);
         if(query1.list().isEmpty()){
        attributeValue = "8c424380-6b54-4749-9d90-bf2bc3792374.gif";
         }else{
            Iterator it = query1.list().iterator();
            while(it.hasNext()){
               attributeValue = (String)it.next();            
            }
         }
        
         Object[] row1 = new Object[2];



//result为一个没有iterator的list对象


   row1[0] = result;
         row1[1] = attributeValue;

         al.add(row1);

action代码为

。。。。。。。。。。。

  Release release = (Release)ServiceLocator.getInstance().getService("release");

result = release.getReleaseProductInfo(productId);

。。。。。。。。。

    public List getResult(){
        return this.result;
    }
   



页面的代码为:测试用的

、//进入一级遍历

<ww:iterator value="result"/>


<!--一级list的长度-->
<ww:property value="top.length"/>

//进入二级遍历


<ww:iterator value="top[0]">


<!--二级list的长度-->
<ww:property value="top.length"/>

<ww:property value="top[0].productId"/>
<ww:property value="top[1].price"/>
<ww:property value="top[2].intro"/>
<ww:property value="top[3].productId"/>
<!--在二级遍历中,取一级中的数据--加个[1],同样的道理,如果是从三级跳到一级,那就[2]
  不过有个问题,如是查从-->
跳出来<ww:property value="[1].top[1]"/>
</ww:iterator>

//下面在一级目录,由于它不是list对象,是个String故不用<ww:iterator value="top[1]">


<ww:property value="top[0].productId"/>   
</ww:iterator>



您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-26 19:39

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表