So I have an inputText
that has its value hook to myBean.text
, I want that if I click enter/return key, the inputText will invoke a method inside myBean
to do something. Can any one help me?
EDIT
<p:inplace label="Add Comment">
<h:inputText id="keyword" value="#{PostComment.comment.comment}" style="width:100%;"
onkeypress="if (event.keyCode == 13){onchange(); return false;}">
<f:ajax event="change" listener="#{PostComment.postCommentListener}"/>
</h:inputText>
<p:watermark for="keyword" value="Comment here"/>
</p:inplace>
then in PostComment
bean
public void postCommentListener(AjaxBehaviorEvent event){
NewsFeed c = scholar.getModel().getRowData();
postProfileComment(c.getTargetFeedId());
}