找不到JSF2 Ajax渲染ID [英] Jsf2 ajax render id not found
问题描述
为什么我得到包含未知ID':commentTextArea'-无法在组件commentLink的上下文中找到它"错误?
Why i get " contains an unknown id ':commentTextArea' - cannot locate it in the context of the component commentLink" error?
majorra 2.1.7
majorra 2.1.7
我如何呈现commentTextArea.
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>
'
推荐答案
ID :commentTextArea
是绝对ID,相对于视图根.但是,ui:repeat
是NamingContainer,并且包装"您的commentTextArea
. (在浏览器中检查html源代码以查看生成了什么ID)
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)
一个简单的解决方案是在"ui:repeat"中仅使用一种形式.然后,相对编号为
A simple solution would be to use only one form in your 'ui:repeat'. Then the relative id with
<f:ajax render="commentTextArea">
(没有:
)会起作用.
这篇关于找不到JSF2 Ajax渲染ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!