0

Why i get " contains an unknown id ':commentTextArea' - cannot locate it in the context of the component commentLink" error?

majorra 2.1.7

How i can render 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>

'

4

1 回答 1

0

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

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

<f:ajax render="commentTextArea">

(没有:)会工作。

于 2012-05-21T09:43:41.600 回答