2012-05-21 35 views
0

爲什麼我得到「包含一個未知的ID」:commentTextArea' - 無法找到它在組件commentLink「的錯誤?Jsf2 ajax渲染ID未找到

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> 

'

回答

0

的ID :commentTextArea是絕對ID和相對於視圖根。但是,ui:repeat是NamingContainer,並「包裝」了您的commentTextArea。 (檢查瀏覽器中的html源代碼以查看生成的id)

一個簡單的解決方案是在'ui:repeat'中只使用一種形式。然後用

<f:ajax render="commentTextArea"> 

(不:)相對ID會工作。

+0

仍然是相同的錯誤,包含一個未知的id'commentTextArea' - 無法找到它在組件commentLink的上下文中。該commentTextArea生成的ID是

+0

您可以使用當前版本更新您的帖子嗎? –

+0

您當前版本的含義。 –