The bug is the inputTextarea
I have below. Only the last row can record any input from the inputTextarea
, in other word, only the last row, hook it value
to #{PostComment.comment.comment}
. Why is this?
<h:form id="userCommentList" >
<p:dataTable value="#{CentralFeed.profileComments}" var="item">
<p:column>
<!-- Original Comment -->
<h:outputText value="#{item.comment}"/>
<!-- ****BUG IS THIS INPUTTEXTAREA BELOW*** -->
<h:inputTextarea id="keyword" value="#{PostComment.comment.comment}"/>
<p:commandButton actionListener="#{PostComment.postProfileComment(item.id)}"
value="Post" update="userCommentList" />
</p:column>
</p:dataTable>
</h:form>
EDIT
I change the inputTextarea
and commandButton
like you suggest BalusC. And inside Comment
entity I add in another field call newComment
, so Comment
look like this
Comment
+ id
+ comment
+ newComment --> I have @Transient to this field so it wont map to the database. I also set its default value to the empty string in the constructor
+ ...
...
<p:column>
...
<h:inputTextarea id="keyword" value="#{item.newComment}" rows="2" />
<p:commandButton actionListener="#{PostComment.postReply(item)}" value="Post" />
</p:column>
I hope the item.newComment
would hold the value I just type in, so when I pass the object item
to postReply
, I can extract the content of newComment out, however it is an empty string. So whatever I type in does not bind to newComment
. Any idea why?