【问题标题】:I don't want p:commandLink redirect我不想要 p:commandLink 重定向
【发布时间】:2013-09-10 12:59:14
【问题描述】:

有人能解释一下为什么以下 commandLink 会重定向吗?

<p:commandLink value="#{popupMsg['painel.informacoes.conta.alterar']}"
               actionListener="#{controladorPopupSelecaoConta.abrir}"
               oncomplete="exibirPopup(xhr,status,args,dlgselecaoConta);"
               title="#{popupMsg['painel.informacoes.conta.alterar.descricao']}"
               update=":selecaoConta :alerta" process="@none"/>

如果我将相同的元素不加任何修改地放在另一个现有的 h:form 中,它会像预期的那样工作(打开一个对话框)。

【问题讨论】:

  • 如果出现 JS 错误(因为它由 JS 完成工作),就会发生这种情况。有没有关注 JS 控制台?
  • chrome 控制台没有错误,glassfish 中也没有异常
  • 好吧,是时候创建和发布一个 SSCCE 了,这样我们(和你自己!)就可以通过复制'n'paste'n'运行 sn-p 到一个空白来重现确切的问题没有任何(非明显)修改的游乐场项目。

标签: ajax jsf-2 primefaces


【解决方案1】:

当我创建 SSCCE 项目以在此处共享时,我注意到 xmlns:p="http://primefaces.org/ui" 未在我使用 p:commandLink 的文件中声明。所以我来自这个:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<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:hrgi="http://java.sun.com/jsf/composite/hrgi">

<ui:component>
     <h:form>
        <p:commandLink value="#{popupMsg['painel.informacoes.conta.alterar']}"
                   actionListener="#{controladorPopupSelecaoConta.abrir}"
                   oncomplete="exibirPopup(xhr,status,args,dlgselecaoConta);"
                   title="#{popupMsg['painel.informacoes.conta.alterar.descricao']}"
                   update=":selecaoConta :alerta" process="@none"/>
    </h:form>
</ui:component>
</html>

到这里:

<ui:component xmlns="http://www.w3.org/1999/xhtml"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:p="http://primefaces.org/ui"
          xmlns:f="http://java.sun.com/jsf/core">
    <h:form>
        <p:commandLink value="#{popupMsg['painel.informacoes.conta.alterar']}"
                   actionListener="#{controladorPopupSelecaoConta.abrir}"
                   oncomplete="exibirPopup(xhr,status,args,dlgselecaoConta);"
                   title="#{popupMsg['painel.informacoes.conta.alterar.descricao']}"
                   update=":selecaoConta :alerta" process="@none"/>
    </h:form>
</ui:component>

【讨论】:

    猜你喜欢
    • 2012-05-15
    • 1970-01-01
    • 1970-01-01
    • 2013-09-10
    • 1970-01-01
    • 1970-01-01
    • 2014-10-30
    • 2018-01-02
    • 1970-01-01
    相关资源
    最近更新 更多