【问题标题】:a href onClick is called on page start up (before clicking on the link)a href onClick 在页面启动时被调用(在点击链接之前)
【发布时间】:2014-08-11 12:28:52
【问题描述】:

我有一个 primefaces 数据表,其中有一列包含指向 ftp 文件的链接:

<p:column sortBy="emplacementlivrable" filterBy="emplacementlivrable">
<a href="ftp://#{spec.emplacementlivrable}" onclick="#{respSpecController.connectToFtpServer()}" target="_blank">#{spec.emplacementlivrable}
</a>
</p:column>

我需要连接到 ftp 服务器的方法,只有当用户点击链接时才会执行。但是当我调试时,我可以看到它在页面启动时调用了该方法,而不仅仅是在单击链接时。

是否有阻止这种行为的原因?

谢谢

【问题讨论】:

    标签: ajax primefaces ftp href


    【解决方案1】:

    这很奇怪,我不知道为什么。但这应该可行:

    <p:commandLink value="#{spec.emplacementlivrable}" 
                   actionListener="#{respSpecController.connectToFtpServer()}" 
                   oncomplete="window.open('ftp://#{spec.emplacementlivrable}'); return false;" 
                   />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-06
      • 1970-01-01
      • 1970-01-01
      • 2014-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-13
      相关资源
      最近更新 更多