Bhe*_*ung 15 ajax dynamic include primefaces jsf-2
在JSF2中,是否可以使用Ajax请求动态更改ui:include的src值(例如PrimeFaces p:commandButton)?谢谢.
<h:form>
<h:commandLink value="Display 2" action="#{fTRNav.doNav()}">
<f:setPropertyActionListener target="#{fTRNav.pageName}" value="/disp2.xhtml" />
</h:commandLink>
</h:form>
<ui:include src="#{fTRNav.pageName}"></ui:include>
Run Code Online (Sandbox Code Playgroud)
这就是我现在所拥有的.是否有可能使它成为Ajax(使用p:commandButton)?
Bal*_*usC 16
另一个答案中提出的JSTL标签不是必需的,并且它不能很好地重复使用.
这是使用纯JSF的一个基本示例(假设您运行Servlet 3.0/EL 2.2,否则您确实需要<f:setPropertyActionListener>像在您的问题中一样使用):
<h:form>
<f:ajax render=":include">
<h:commandLink value="page1" action="#{bean.setPage('page1')}" />
<h:commandLink value="page2" action="#{bean.setPage('page2')}" />
<h:commandLink value="page3" action="#{bean.setPage('page3')}" />
</f:ajax>
</h:form>
<h:panelGroup id="include">
<ui:include src="#{bean.page}.xhtml" />
</h:panelGroup>
Run Code Online (Sandbox Code Playgroud)
同
private String page;
@PostConstruct
public void init() {
this.page = "page1"; // Ensure that default is been set.
}
// Getter + setter.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20162 次 |
| 最近记录: |