Ajax如何在JSF上工作?

时间:2022-10-13 15:00:02

I am new to JSF, but I have some experience with ASP.NET and its Ajax features. I know that JSF has some Ajax tags that can do some duties with Ajax, but I wonder how it uses Ajax. Does it use something like ScriptManager in ASP.NET?

我是JSF的新手,但我对ASP.NET及其Ajax功能有一些经验。我知道JSF有一些Ajax标签可以用Ajax做一些工作,但我想知道它是如何使用Ajax的。它在ASP.NET中使用类似ScriptManager的东西吗?

1 个解决方案

#1


4  

Whenever you use the JSF <f:ajax> tag, the jsf.js script will be auto-included in the HTML head. It will take care about all the ajax magic. The on* attributes of the generated HTML elements will where necessary be altered that way so that it uses the ajax script rightly. You don't need to worry about this all, all you need to do is to specify and use the JSF <f:ajax> tag as documented. You don't need to manually include and configure the script like as ASP.NET ScriptManager.

每当您使用JSF 标记时,jsf.js脚本将自动包含在HTML头中。它会照顾所有的ajax魔法。生成的HTML元素的on *属性将在必要时以这种方式进行更改,以便正确使用ajax脚本。您无需担心这一切,您需要做的就是指定并使用JSF 标记。您不需要像ASP.NET ScriptManager那样手动包含和配置脚本。

Note that this only works when you use Facelets as view technology, not its ancient predecesor JSP. You also need to make sure that you've a <h:head> instead of plain HTML <head> in the master template, otherwise JSF won't be able to auto-include the jsf.js script.

请注意,这只适用于将Facelets用作视图技术,而不是其古老的前置JSP。您还需要确保在主模板中有一个 而不是纯HTML ,否则JSF将无法自动包含jsf.js脚本。

All with all, JSF ultimately generates plain HTML. Just open page in browser, rightclick and View Source. If you are well familiar with basic HTML and JS, everything will be obvious.

总而言之,JSF最终生成纯HTML。只需在浏览器中打开页面,右键单击并查看源代码。如果您熟悉基本的HTML和JS,一切都会很明显。

#1


4  

Whenever you use the JSF <f:ajax> tag, the jsf.js script will be auto-included in the HTML head. It will take care about all the ajax magic. The on* attributes of the generated HTML elements will where necessary be altered that way so that it uses the ajax script rightly. You don't need to worry about this all, all you need to do is to specify and use the JSF <f:ajax> tag as documented. You don't need to manually include and configure the script like as ASP.NET ScriptManager.

每当您使用JSF 标记时,jsf.js脚本将自动包含在HTML头中。它会照顾所有的ajax魔法。生成的HTML元素的on *属性将在必要时以这种方式进行更改,以便正确使用ajax脚本。您无需担心这一切,您需要做的就是指定并使用JSF 标记。您不需要像ASP.NET ScriptManager那样手动包含和配置脚本。

Note that this only works when you use Facelets as view technology, not its ancient predecesor JSP. You also need to make sure that you've a <h:head> instead of plain HTML <head> in the master template, otherwise JSF won't be able to auto-include the jsf.js script.

请注意,这只适用于将Facelets用作视图技术,而不是其古老的前置JSP。您还需要确保在主模板中有一个 而不是纯HTML ,否则JSF将无法自动包含jsf.js脚本。

All with all, JSF ultimately generates plain HTML. Just open page in browser, rightclick and View Source. If you are well familiar with basic HTML and JS, everything will be obvious.

总而言之,JSF最终生成纯HTML。只需在浏览器中打开页面,右键单击并查看源代码。如果您熟悉基本的HTML和JS,一切都会很明显。