如何AJAX JSF 2 outputLink的 [英] How to ajax jsf 2 outputLink
问题描述
我想对正在工作的AJAX(一切AJAX)的网页。我的意思..当你点击一个链接(我指到< H:outputLink的...>),以使用来自另一个链接数据变化有一定的div
I want to make a webpage that is working on ajax(everything ajax). I mean.. whenever you click a link(I refer to < h:outputLink ...> ) to change a certain div using data from another link.
例如:
<h:outputLink value="/page.jsf" onclick="myfunction(this); return false;">
My page
</h:outputLink>
page.jsf是一个正常的JSF页面...使用页面layout.xhtml想显示:
page.jsf is a normal jsf page... displayed using a page layout.xhtml like:
<ui:composition template="/layout.xhtml">
<ui:define name="main">
//my content here
</ui:define>
</ui:composition>
这可能吗? 这是可能的,使用servlet采取的碎片从一个特定的JSF?
Is this possible? Is this possible, using a servlet to take only fragments from a specific jsf?
我最后的解决方案是使用jquery.load功能...
My last solution is to use jquery.load function...
问候
推荐答案
&LT; H:链接&GT;
和&LT; H:outputLink的&GT;
不能Ajax化。所有JSF2 Ajax请求是按规格POST请求。你需要一个&LT; H:形式GT;
与&LT; H:commandLink&GT;
<h:link>
and <h:outputLink>
cannot be ajaxified. All JSF2 ajax requests are per specification POST requests. You need a <h:form>
with a <h:commandLink>
.
您可以使用下面的结构:
You could use the following construct:
<h:form>
<f:ajax render=":include">
<h:commandLink value="Home" action="#{menuManager.setPage('home')}" /><br />
<h:commandLink value="FAQ" action="#{menuManager.setPage('faq')}" /><br />
<h:commandLink value="Contact" action="#{menuManager.setPage('contact')}" /><br />
</f:ajax>
</h:form>
<h:panelGroup id="include">
<ui:include src="#{menuManager.page}.xhtml" />
</h:panelGroup>
这篇关于如何AJAX JSF 2 outputLink的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!