Ajax如何在JSF上工作? [英] How does Ajax work on JSF?

查看:92
本文介绍了Ajax如何在JSF上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JSF的新手,但是我对ASP.NET及其Ajax功能有一些经验.我知道JSF有一些Ajax标记可以与Ajax一起执行某些任务,但是我不知道它如何使用Ajax.它在ASP.NET中使用诸如ScriptManager之类的东西吗?

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 jsf.js 脚本将自动包含在HTML头中.它将处理所有的ajax魔术.生成的HTML元素的on*属性将在必要时进行更改,以使其正确使用ajax脚本.您无需担心所有这些,您所需要做的就是指定和使用所记录的JSF <f:ajax>标记.您无需像ASP.NET ScriptManager一样手动包含和配置脚本.

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.

请注意,这仅在将Facelets用作视图技术时才有效,而不是其古老的前身JSP.您还需要确保在主模板中使用的是<h:head>而不是纯HTML <head>,否则JSF将无法自动包含jsf.js脚本.

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.

总而言之,JSF最终生成纯HTML.只需在浏览器中打开页面,右键单击并查看源代码.如果您熟悉基本的HTML和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.

这篇关于Ajax如何在JSF上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆