Jsf2 ajax render id not found

你离开我真会死。 提交于 2019-12-13 03:59:29

问题


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>

'


回答1:


The id :commentTextArea is an absolute id and relative to the view root. However, ui:repeat is a NamingContainer and "wraps" your commentTextArea. (Check the html source in browser to see what id is generated)

A simple solution would be to use only one form in your 'ui:repeat'. Then the relative id with

<f:ajax render="commentTextArea">

(without :) would work.



来源:https://stackoverflow.com/questions/10682302/jsf2-ajax-render-id-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!