a4j:commandButton oncomplete在调用其他组件中的单击时给出NS_ERROR_FAILURE

时间:2016-01-19 19:07:26

标签: jsf firefox richfaces

当a4j:commandButton的oncomplete刚刚完成时,我正在尝试从html链接调用一个单击(id = btnPreview1),但是,firefox(其他浏览器很好)启动 NS_ERROR_FAILURE :。在谷歌搜索其他案例,发现这可能是一个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>

Richfaces 4.3.2 jsf 2.1.26(mojarra) FF 43.0.4

TKS,

韦斯克利

1 个答案:

答案 0 :(得分:0)

我不确定你能不能写:

document.getElementById('btnPreview1')

与RichFaces一样。

尝试:

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

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

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

JSF richfaces getElementById