【问题标题】:a4j:commandButton oncomplete give NS_ERROR_FAILURE when invoke a click in other componenta4j:commandButton oncomplete 在调用其他组件中的单击时给出 NS_ERROR_FAILURE
【发布时间】:2016-01-19 19:07:26
【问题描述】:

我正在尝试在 a4j:commandButton 的 oncomplete 刚刚完成时从 html 链接调用一次点击 (id=btnPreview1),但是,firefox(其他浏览器很好)正在启动 NS_ERROR_FAILURE:。在 google 上搜索其他情况,发现这可能是 XSS 验证错误。我该如何解决?

P.S 对不起,我的英语水平很差

<h:html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions">

<h:head>
    <script type="text/javascript">
        function exec(data){

          if(data.status=='success'){
             //alert(data.status + " " + $("btnPreview1"));
              //$("btnPreview1").submit();
             document.getElementById("btnPreview1").click();
          }
        }

    </script>
</h:head>

<h:body>

    <h:form id="formZica" prependId="false">
        <h:panelGrid id="page" columns="1">
            <rich:panel id="panelParametros">

                <f:facet name="header">
                    <h:panelGrid columns="1">
                        <h:outputText styleClass="subTitulo" value="Parâmetros" />
                    </h:panelGrid>
                </f:facet>


                <h:outputText value="Test field" />
                <h:inputText id="field" required="true" />
                <h:message for="field" />

                <h:outputText value="#{facesContext.validationFailed}" />
            </rich:panel>


            <br />
            <br />

            <h:panelGroup>


                <a4j:commandButton id="btnPreview" value="View"
                                oncomplete="if (#{not facesContext.validationFailed}) { document.getElementById('btnPreview1').click();};"
                    render="panelParametros" />



                <h:commandButton id="btnPreviewNwe" value="View version with f:ajax" >


                    <f:ajax render="panelParametros" execute="@form" onevent="exec"/>
                </h:commandButton>  

                <h:commandLink target="_blank" id="btnPreview1"
                     value="testeff" />



            </h:panelGroup>
        </h:panelGrid>
    </h:form>

</h:body>
</h:html>

富脸 4.3.2 jsf 2.1.26 (mojarra) FF 43.0.4

tks,

韦斯利

【问题讨论】:

    标签: jsf firefox richfaces


    【解决方案1】:

    我不确定你能不能写:

    document.getElementById('btnPreview1')
    

    就像 RichFaces 一样。

    试试:

    document.getElementById("#{rich:clientId('btnPreview1')}")
    

    我希望这可以解决您的问题。

    http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=functions&skin=blueSky

    JSF richfaces getElementById

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-20
      • 1970-01-01
      • 2012-06-02
      • 2017-09-28
      • 1970-01-01
      • 2021-07-24
      相关资源
      最近更新 更多