<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE page-specification PUBLIC "-//Apache Software Foundation//Tapestry Specification 4.0//EN" "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd"> <page-specification class="ActionPage"> <property name="host"/> <property name="storage"/>
<component id="host" type="Foreach"> <binding name="source" value="ognl:getAIXHostInfo('1118')"/> <binding name="value" value="host"/> <binding name="element" value="literal:tr"/> </component> <component id="storage" type="Foreach"> <binding name="source" value="ognl:getAIXHostInfo('1119')"/> <binding name="value" value="storage"/> <binding name="element" value="literal:tr"/> </component> <component id="host_id" type="Insert"> <binding name="value" value="host.id"/> </component> <component id="host_name" type="Insert"> <binding name="value" value="host.name"/> </component> <component id="host_type" type="Insert"> <binding name="value" value="host.type"/> </component> <component id="host_IP" type="Insert"> <binding name="value" value="host.IP"/> </component> <component id="host_useOf" type="Insert"> <binding name="value" value="host.useOf"/> </component> <component id="storage_id" type="Insert"> <binding name="value" value="storage.id"/> </component> <component id="storage_name" type="Insert"> <binding name="value" value="storage.name"/> </component> <component id="storage_type" type="Insert"> <binding name="value" value="storage.type"/> </component> <component id="storage_IP" type="Insert"> <binding name="value" value="storage.IP"/> </component> <component id="storage_useOf" type="Insert"> <binding name="value" value="storage.useOf"/> </component> <component id="displayAIXHostInfo" type="DirectLink"> <binding name="listener" value="listener:linkToPage"/> <binding name="parameters" value="'{'+'AIXHostInfo','showAixHostInfo&id='+host.id+'}'"/> </component> </page-specification> 请教:
1。在DirectLink组件中,host.id这里 改成storage.id就出错误,显示为空,为什么,我storage明显是能取出对象里的属性的,因为在没有加storage.id之前还是可以循环显示的
2。IPage方法里 得到DirectLink里绑定的参数时,objects[] 里只有一个参数 object[0] 我的意图是2个参数
一个是AIXHostInfo(字符串) 一个是showAixHostInfo&id=host.id(这里的host.id是动态参数),结果得到的却不是这样的 只有一个参数 打印object[0]结果是“showAixHostInfo&id=54682}”
第二问 我自己搞定了 现在只剩下第一个问题 请大家帮助,第二个问题 是我把ognl表达式写复杂了 其实很简单的就可以实现了 改如下: <binding name="parameters" value="{'AIXHostInfo','showAixHostInfo&id='+host.id}"/> 这样就可以了
按照你的描述,我怀疑你的storage_id在页面上是否放入到Foreach的循环范围?
如果HTML格式不复杂,可以贴上来看看。
<table > <tr jwcid="storage"> <td><a href="#"><span jwcid="storage_name"/></a></td> <td><span jwcid="storage_type"/></td> <td><span jwcid="storage_IP"/></td> <td><span jwcid="storage_useOf"/></td> </tr> </table>
刚才没登陆 现在提交上来了 为什么
不让ID显示在页面上 难道一定要放一个隐藏域把ID循环出来吗 然后在点击的时候才能得到ID?
没有包括storage_id,这个是当然啊,foreach作为循环,不停循环它所包围的HTML标签,已经运行T4组件。。。循环以外,foreach不起作用, <property name="storage"/>的storage始终为null,你肯定取不出其中字段。
呵呵,可能你的浏览器保存了session
你要允许“点击”,可以放在链接组件的参数里面啊。
再说明白一点,<porperty name="storage"/>就好比定义了一个临时容器,foreach或for组件,再每次循环的时候,往这个临时容器塞入一个循环遍历对象。。。循环结束,这个临时容器就空了。循环以外,这个临时容器并没有被塞入过任何对象,自然也是空的呀。
揭贴 问题解决