【问题标题】:Jsf2 ajax render id not found未找到 Jsf2 ajax 渲染 ID
【发布时间】:2012-05-27 18:42:28
【问题描述】:

为什么我得到“包含未知 id ':commentTextArea' - 无法在组件 commentLink 的上下文中找到它”错误?

majorra 2.1.7

我如何渲染commentTextArea。

<ui:repeat var="parentComment" value="#{commentTree.parentCommentsWrapper}"> ....
                          <h:form>

                            <h:commandLink id="commentLink" value="comment"
                                style="height:20px;width:20px;padding: 0; margin: 0;"
                                action="#{parentComment.changeEditable}">
                                **<f:ajax render=":commentTextArea"></f:ajax>**
                            </h:commandLink>

                            </h:form>        <h:panelGroup id="commentTextArea">
                                <br />
                                <h:panelGroup rendered="#{parentComment.editable}">
                                    <h:form >
                                    <h:inputTextarea rows="2" cols="20"
                                        value="#{commentTree.newCommentText}" 
                                        style="font-family:Arial,Helvetica;font-size:12px;width:365px;margin-right: 4px;margin-left: -1px;">
                                    </h:inputTextarea>
                                    <h:commandButton id="newCommentButton" value="+"
                                        style="height:20px;width:20px;padding: 0; margin: 0;"
                                        action="#{commentTree.saveChildComment(parentComment.comment)}" >
                                    </h:commandButton>
                                    </h:form>
                                </h:panelGroup>
                            </h:panelGroup>
</ui:repeat>

'

【问题讨论】:

    标签: ajax jsf-2 render


    【解决方案1】:

    id :commentTextArea 是一个绝对 id 并且相对于视图根。但是,ui:repeat 是一个 NamingContainer 并“包装”您的 commentTextArea。 (查看浏览器中的html源代码,看看生成了什么id)

    一个简单的解决方案是在“ui:repeat”中只使用一种形式。然后是相对id与

    <f:ajax render="commentTextArea">
    

    (没有:)会起作用。

    【讨论】:

    • 还是同样的错误, 包含一个未知的 id 'commentTextArea' - 无法在组件 commentLink 的上下文中找到它。该commentTextArea 生成的ID 是
    • 你说的当前版本是什么意思。
    • 只有一种形式的版本。
    • 这是我唯一的版本。我不能把所有东西都放在一种形式中。如果我这样做了,只有循环中的最后一个命令链接将数据提交到支持 bean。其他链接不填充支持 bean。请帮我让它工作。非常感谢。
    • 哦,可能我还不够清楚。我想到了一种 inside ui:repeat 的形式。
    猜你喜欢
    • 2011-08-22
    • 2011-09-29
    • 2011-11-26
    • 1970-01-01
    • 2011-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多