Jsf h:commandLink和onclick Javascript函数

Jsf h:commandLink和onclick Javascript函数,jsf,seam,Jsf,Seam,我有以下和平的准则: <DIV> <h:commandLink action="#{documentGen.generatePDF}" target="_blank" onclick="return checkSelected();"> <h:graphicImage url="/images/pdf.jpg" styleClass="pdfimage" title="Click to show

我有以下和平的准则:

<DIV>
    <h:commandLink action="#{documentGen.generatePDF}"
        target="_blank"
        onclick="return checkSelected();">
        <h:graphicImage url="/images/pdf.jpg"
        styleClass="pdfimage" title="Click to show PDF"></h:graphicImage>
    </h:commandLink>
</DIV>
并在命令链接中单击to:
onclick=“return testFunc();”

结果是我收到警报“get Here!”,但与以前一样,新窗口与当前窗口重复,backbean不会被调用。删除onclick行会更正结果(但需要javascript函数检查复选框)

在浏览器源代码视图中,不带onclik和带onclick的commandlink之间的区别如下:

  <a href="#" onclick="return oamSubmitForm('genView','genView:_idJsp33','_blank',[]);" id="genView:_idJsp33" target="_blank"><img src="/images/pdf.jpg" title="Click for Pdf Document" class="pdfimage"></a>


  <a href="#" onclick="return testFunc();;return oamSubmitForm('genView','genView:_idJsp33','_blank',[]);" id="genView:_idJsp33" target="_blank"><img src="/images/pdf.jpg" title="Click for Pdf Document" class="pdfimage"></a>


任何帮助都将不胜感激。谢谢

如果在commandLink的onclick事件中返回false,则不会提交表单

如果在commandLink的onclick事件中返回false,则不会提交表单

问题是您总是返回。我认为你想要的只是在必要时返回false,否则继续

因此,将onclick更改为

onclick=“if(checkSelected()){return false;}”


这肯定是Ajax提交表单的一个问题,因为如果您以前返回表单,则不会调用submit。我可以想象,这对标准表单的提交也很重要。

问题是您总是返回。我认为你想要的只是在必要时返回false,否则继续

因此,将onclick更改为

onclick=“if(checkSelected()){return false;}”


这肯定是Ajax提交表单的一个问题,因为如果您以前返回表单,则不会调用submit。我可以想象,这也算是标准的表单提交。

非常感谢你,你说得对。非常感谢,你说得对。
  <a href="#" onclick="return oamSubmitForm('genView','genView:_idJsp33','_blank',[]);" id="genView:_idJsp33" target="_blank"><img src="/images/pdf.jpg" title="Click for Pdf Document" class="pdfimage"></a>


  <a href="#" onclick="return testFunc();;return oamSubmitForm('genView','genView:_idJsp33','_blank',[]);" id="genView:_idJsp33" target="_blank"><img src="/images/pdf.jpg" title="Click for Pdf Document" class="pdfimage"></a>