【发布时间】:2016-12-06 19:22:21
【问题描述】:
几天来,我一直在尝试获得一个具有自动完成功能的“通用”对话框。事实证明,我只是以“错误的方式”创建 MethodExpression。所以我想我会在这里记录下来。
重申一下:您希望动态创建 MethodExpression,将其存储在 Property 中并在 JSTL 模板或 JSF 页面中使用。
例如:
// Template
<c:forEach items="#{property.subItems}" var="subitem">
<ui:include src="editor.xhtml">
<ui:param name="autocompleteMethod" value="#{subitem.autocompMethod}" />
</ui:include>
</c:forEach>
// editor.xhtml
// We're using RichFaces (unfortunately), but this is just an example
<rich:autocomplete mode="cachedAjax" minChars="2"
autocompleteMethod="#{autocompleteMethod}"
/>
【问题讨论】:
-
你觉得这是复制品吗?您链接的问题使用 OmniFaces 和 PrimeFaces 等特定框架来解决问题。这里主要是如何从代码构造 MethodExpression。我可能在 RichFaces 小部件中使用它,但这只是一个使用示例,可以替换。该解决方案本身是纯 JSF 并适用于所有 *Faces 框架。
标签: jsf richfaces el uiinclude methodexpression