jsf - 如何在 JSF 1.2/Richfaces 3.3 中在渲染时调用 Javascript 函数?

标签 jsf richfaces jsf-1.2

我们有一个 a4j:outputPanelajaxRendered .有没有办法在每次(重新)渲染时调用 javascript 函数?我知道我们可以在每个可能提交的元素中调用 oncomplete ,但这实际上是不可维护的。

细节:

  • JSF 1.2
  • Richfaces 3.3

  • 示例(oncomplete 在 outputPanel 标签上实际上不可用):
    <a4j:outputPanel ajaxRendered="true" oncomplete="myJSFunc()">
        <h:outputText value="Test-aroo" />
    </a4j:outputPanel>
    <!-- other inputs, buttons and stuff -->
    

    更新 jQuery 库能否提供帮助(它内置于 RichFaces 中)?我正在考虑使用 .live() 来注册 oncomplete 事件。我会继续尝试并随着进度更新。

    更新 我没有机会实现 jQuery 解决方案,但正如我的回答如下所示 myJSFunc()可以直接放在渲染的标签中。

    最佳答案

    一种解决方案是将 javascript 放在 outputPanel 内的脚本标记中:

    <a4j:outputPanel ajaxRendered="true">
        <h:outputText value="Test-aroo" />
        <script type="text/javascript">myJSFunc();</script>
    </a4j:outputPanel>
    

    关于jsf - 如何在 JSF 1.2/Richfaces 3.3 中在渲染时调用 Javascript 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7852115/

    相关文章:

    java - CANNOT_FIND_FACELET_TAGLIB 对于 xmlns :jsf ="http://xmlns.jcp.org/jsf"

    java - Spring上下文配置

    hibernate - javax.el.PropertyNotFoundException : Property not found on type org. hibernate.collection.internal.PersistentSet

    java - Richfaces a4j :commandButton not working when enabled after a ajax response

    gradle - 使用Gradle设置Richfaces-NLS缺少消息:CANNOT_FIND_FACELET_TAGLIB

    jQuery 在 f :ajax 之后应用 css 类

    java - RichFaces fileUpload 无法调用监听器

    java - 如何在jsf2中添加请求参数?

    jsf - java.lang.UnsupportedOperationException : Cannot set ServletRequest Parameter

    javascript - JSF 1.2 : How to open a new window and catch the fact that user tried it