【问题标题】:p:commandLink not fires actionp:commandLink 不触发动作
【发布时间】:2013-02-08 15:22:59
【问题描述】:

p:commandLinks 的 ID 为 cl1 和 cl2 不会触发操作。 Tomcat 控制台上什么都没有,Firebug 控制台上什么都没有。

在这种情况下我应该在哪里寻找问题,我想我完全绝望了,在两个控制台中都没有任何错误或异常。

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:c="http://java.sun.com/jsp/jstl/core"
        xmlns:o="http://openfaces.org/"
        xmlns:p="http://primefaces.org/ui">
    <h:form>
        <ui:repeat var="sharing" value="#{sharingController.myList}">
            <ui:repeat var="sharingComment" value="#{sharing.subCommentList}">
                <p:commandLink id="cl1" value="" process="@this"  action="#{reportController.reportSharingComment(sharingComment)}" style="float:right;" id="sharingComment_alert" styleClass="icon_alert" title="#{msg['label.report']}" update=":messages" >
                </p:commandLink>
                 <p:commandLink value="" id="cl2" process="@this" action="#{sharingController.deleteComment(sharingComment)}" style="float:right;" id="sharingComment_delete" styleClass="icon_delete" title="#{msg['label.delete']}" update="@form :messages">
                </p:commandLink>
            </ui:repeat>
        </ui:repeat>
    </h:form>
</ui:composition>

我尝试在 post 构造中使用嵌套 ui:repeat 中的具体列表,然后触发命令链接,但我必须遍历字段列表,例如 myList 中每个共享的子评论列表。我正在加载myList,并且对于每次共享,我都会在 for in post 构造中加载subCommentlist,但我仍然无法使commandLinks 着火。

【问题讨论】:

  • 可以只贴相关代码吗? &lt;ui:remove&gt; 标签中有数百行标记,完全没有必要。
  • 有时,SO成员告诉分享一切以找出问题,我要删除ui:removes
  • 你确定这个组件不在另一个&lt;h:form&gt; 中吗?因为那将是form 嵌套,所以你的UIInputs 将不起作用。另外,下次只需发布相关代码以重现问题,而不是您的整个代码。更多信息:h:commandLink / h:commandButton is not being invoked
  • 此&lt;ui:composition&gt; 包含在另一个xhtml 页面中,但没有其他覆盖&lt;h:form&gt;
  • 代码噪音太大。我无法想象例如style="border: 1px solid #AAAAAA;" 与问题有关。删除后问题会消失吗?不?那就别说了。请编辑您的问题以发布真正的 SSCCE。也就是说,我们(和你!)应该能够在完全空白的游乐场项目中复制'n'paste'n'run未经修改的最小可能代码sn-p,并将所有内容设置为默认值(除非另有说明),以便自己看具体问题。

标签: jsf primefaces


【解决方案1】:

h:commandLink / h:commandButton is not being invoked

4.点解决: 将 bean 放入视图范围和/或确保将数据模型加载到 bean 的(后)构造函数中(因此不在 getter 方法中!)应该修复它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-19
    • 2012-01-06
    • 1970-01-01
    • 2013-01-31
    • 1970-01-01
    • 2013-08-09
    • 1970-01-01
    • 2012-12-08
    相关资源
    最近更新 更多