dataTable如何当前行的对象到backing-bean里面?
|
richmond
2008-04-17
大约是这种情况,最后一列都是一个按钮,bean.action里面会对一个item进行操作,当然希望的是每一行对应的那个rowItem了
<h:dataTable value="#{itemList}" var="rowItem">
<h:column>
<h:commandButton action="bean.action"/>
</h:column>
</h:dataTable>
但是我如何将这个item传到bean里面呢? 试了一下在commandButton里面加入<f:attribute>或者<f:param>,value="rowItem"好像都是空值 请大家帮帮初学者吧,先谢过了 |
|
|
stenlylee
2008-04-24
commandButton不能加f:param,换commandLink
|
|
|
kencool
2008-04-24
itemList就是你想要的,JSF会自动将页面数据写入后台Bean中
|
|
|
tailsherry
2008-04-28
在你的后台bean中声明一个UIData类型的变量tableRowData,然后在dataTable tag的属性中加入binding="#{tableRowData}".
在你的command action对应的事件中,通过obj = tableRowData.getRowData();来获取当前的行对象。 |
|
|
terryzhou
2008-05-04
stenlylee兄和tailsherry兄的两种方法都可以...
一种值binding,一种控件binding. |
|
|
richmond
2008-05-22
谢谢大家
用tailsherry的方法做出来了 stenlylee的方法还有一点不懂,在后台怎么拿到这个param呢? 这个param是加在了commandLink这个组件下面了,但是没用到actionListener的话我怎么才能拿到这个组件? |

