2011-06-29 30 views
0

我只是将我的项目移动到JSF2.0,并且我遇到了这个问题。我只是不能得到一个h:repeat内的inputTextarea。重复之外,伟大的作品...JSF 2.0 - 问题'h:inputTextarea'嵌套在'h:repeat'中

有没有人知道这个解决方案?我猜这是一件简单的事情。

的观点:(只要紧)

<ui:repeat value="#{pub.commentList}" var="com"> 
    <h:panelGroup> 
         <h:form id="pub" >            
          <h:inputTextarea id="comment2" value="#{classController.msgComment}" />       
          <div> 
           <h:commandButton type="submit" value="Postar" action="#{classController.saveComment}" />        
          </div> 
         </h:form> 
        </h:panelGroup> 
    </ui:repeat> 

塔豆是一切正常。只需获取/设置属性“msgComment”即可。

感谢您的回复!

+1

您将h:inputText的所有实例绑定到一个属性。我看不出这会如何工作。无论如何,你究竟做了什么? –

回答

0

您需要将该值绑定到当前迭代的对象,而不是父托管bean。

<h:inputTextarea id="comment2" value="#{com.msgComment}" /> 
0

我想你想要做的是什么(假设你的容器支持EL 2.2):

<ui:repeat value="#{pub.commentList}" var="com"> 
    <h:panelGroup> 
     <h:form id="pub" >            
      <h:inputTextarea id="comment2" value="#{com.msgComment}" />       
      <div> 
       <h:commandButton type="submit" value="Postar" action="#{classController.saveComment(com)}" />        
      </div> 
     </h:form> 
    </h:panelGroup> 
</ui:repeat> 

而在你classController豆:

public String saveComment(Comment com) { 
    //do stuff 
    return "success"; //or anything 
} 

如果你不”没有EL 2.2,你应该用setPropertyActionListener做一些简单的解决方法。