【问题标题】:h:commandLink with f:ajax not renderingh:commandLink 与 f:ajax 不呈现
【发布时间】:2019-05-14 15:15:29
【问题描述】:

从 Wildfly 8 迁移到 16 和 Java 8 到 11 后,我一直面临影响 JSF h:commandLinkf:ajax 的问题。

我尝试渲染:mainformmainform@form ...但没有一个工作。我必须手动重新加载页面才能看到更改。

<h:form id="mainform">
    <div id="adiv">
    ...
      <h:commandLink value="Change statut" styleClass="grey" rendered="#{not bean.condition}">
        <f:ajax event="click" listener="#{bean.switchStatus}" execute="@this" render="@form" />
      </h:commandLink>
    </div>
</h:form>

WF8 和 java 8 一切正常。

我该如何解决?

编辑:我尝试使用 Richfaces 和 a4j:commandLink

<a4j:commandLink value="Click here" reRender="@form"  actionListener="#{bean.switchStatus}"/>

<a4j:commandLink value="Click here" render="@form" execute="@form" actionListener="#{bean.switchStatus}"/>

仍然没有渲染..状态已更改但页面表单未刷新。

编辑: 经过一些研究,javascript呈现似乎是一个错误: 当我删除此功能时渲染工作:

<script type="text/javascript">
                        //<![CDATA[
                        var interval;
                        function countDown(){
                            var countdown=$("#countdown");
                            var count=20;
                            if(interval){
                                clearInterval(interval);
                            }
                            interval=setInterval(function(){
                                count--;
                                if(count > 0) {
                                    countdown.text(count);
                                } else {
                                    clearInterval(interval);
                                    interval=undefined;
                                    $("#cancelLnk").remove();
                                }
                            },1000);
                        }
                        function onCancel(data){
                            if(data&&data.status=="begin"&&interval){
                                clearInterval(interval);
                                interval=undefined;
                            }
                        }
                        //]]>
                    </script>

【问题讨论】:

标签: jsf jsf-2.3


【解决方案1】:

目前,我已将所有 js CDATA 脚本移到表单之外,以便能够呈现它。

【讨论】:

  • 那么我预计浏览器控制台中的某处会出现“嵌套 cdata”错误
  • 对!在预览部分,我有一个 &lt;parseerror&gt;,他在 CDATA //]]&gt; 结束时停止渲染。
  • 所以下次调查这样的事情......你会提前知道并且可能会创建一个不同的问题
猜你喜欢
  • 2012-12-24
  • 1970-01-01
  • 2011-07-19
  • 2012-04-13
  • 2014-02-22
  • 1970-01-01
  • 2011-07-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多