我了解到核心 JSF 组件支持 f:param 和 f:attribute 标记,以便将一些值传递到服务器端以用于封闭的 UI组件。
我需要能够为 primefaces 的自动完成组件执行此操作, 以便自动完成方法能够使用 f:param 或 f:attribute 提供的参数。 我尝试找出实现此目的的方法,发现完整的方法参数是固定的,不能接受更多参数, 因此我正在考虑使用 f:param 或 f:attribute。
我使用 2.2.x 版本,根据我的实验,我似乎无法让 f:param 或 f:attribute 工作
<p:autocomplete ...>
<f:param name="myParam" value="xxxx" />
</p:autocomplete>
primefaces 是否会在自动完成组件上支持此功能? 无论如何,我可以找出哪些标签支持参数,哪些标签不支持?
谢谢!
最佳答案
我终于成功了!
这是 jsf 部分:
<p:autoComplete id="#{cc.attrs.id}" label="#{cc.attrs.label}"
....
completeMethod="#{filterableRaceAutocompleteBean.filterRace}">
<f:attribute name="filter" value="#{cc.attrs.filter}" />
</p:autoComplete>
这是来源:
public List<Dto> filterRace(String filterString) {
String filterValue = (String) UIComponent.getCurrentComponent(FacesContext.getCurrentInstance()).getAttributes().get("filter");
log.debug("filter string : " + filterString + ", with query filter of : " + filterValue);
....
return result;
}
关于jsf - :param or f:attribute support on primefaces autocomplete?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6567002/