【发布时间】:2011-02-11 00:55:59
【问题描述】:
我正在寻找以下问题的解决方案: _The 是不同类型汽车的链接列表。 _用户可以点击列表中的每辆车,并发送一个ajax请求。 _ajax 请求的响应应该依赖于(每辆车的)id 并显示在一个 panelGroup 中。
所以我需要的是在 backing-bean 上调用方法的可能性。此外,调用此方法时应使用汽车 ID 作为其参数。
到目前为止,我的代码如下所示:
...
function showDetails(detailsFor){
jsf.ajax.request(this, event, {render: 'form1:carDetails'});
}
...
<ul>
<ui:repeat value="#{carTree.getCars)}" var="car">
<h:outputScript name="jsf.js" library="javax.faces" target="head" />
<li onclick="showDetails(#{car.id});">#{car.name}</li>
</ui:repeat>
</ul>
...
<h:panelGroup id="carDetails" layout="block" style="float:left;">
// need the details of each 'selected /clicked' car here
</h:panelGroup>
...
backing bean 中的方法应该是这样的:
public class CarTree {
...
public String getCarDetails(int carid){
return "The car details for the car id "+carid+" are......";
}
...
}
我不知道如何使用新的 JSF 2.0 AJAX 功能调用方法。请帮帮我...
【问题讨论】: