且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在JSF2中为渲染AJAX部件添加JS效果?

更新时间:2023-12-05 18:24:46

使用Primefaces很容易:

It's easy if you use Primefaces:

http://www.primefaces.org/showcase/ui/effects.jsf

否则,您可以使用f:ajax标记的onevent属性,该属性接受Java语言函数名称作为值.在AJAX请求期间,将调用该函数三次:在函数参数的状态字段中设置begincompletesuccess.

Otherwise you could use the onevent attribute of the f:ajax tag, which accepts a Javascript function name as the value. This function will be called three times during an AJAX request: with begin, complete and success set in the function parameter's status field.

请查看"Java Server Faces 2.0-完整参考"的第355页以获取更多信息.

Check page 355 of "Java Server Faces 2.0 - The Complete Reference" for further info.

您可以在此处看到一个有效的示例:

You can see a working example here:

http://www.ibm.com/developerworks /java/library/j-jsf2fu3/index.html

更新:来自Primefaces用户指南:

UPDATE: From the Primefaces users guide:

在第一次加载页面时或在ajax请求完成之后,效果也可以应用于任何JSF组件.下面的示例在ajax请求后对具有脉冲效果的消息进行动画处理.

Effects can also be applied to any JSF component when page is loaded for the first time or after an ajax request is completed. Following example animates messages with pulsate effect after ajax request.

<p:messages id="messages"> 
    <p:effect type="pulsate" event="load"> 
        <f:param name="mode" value="'show'" /> 
    </p:effect>
</p:messages> 
<p:commandButton value="Save" actionListener="#{bean.action}" update="messages"/>