I am currently working on a primefaces webapp and I have the following problem:
I create p:inputText
fields dynamically inside an ui:repeat
. There is a list with users and for each user an input can be made. To keep track of this input-to-user-mapping I had to use a map to use key-value pairs. As soon as a input for one of the users is made, a action needs to be called on the blur event. This is no validation, but a kind of calculation which influences the other inputfields.
My problem is, that the action is not getting called, if the input field was created by the ui:repeat
.
I hope I illustrated the problem properly. Please see the code below. Does someone knows a workaround or solution for this? Maybe there is another way to implement this usecase, but I am not aware of it.
edit1: I added the backing bean. As I dont know which method needs to be called, I made a little overloading. Other components (commandbuttons and others) work well with the xhtml and the backing bean, so I removed them for a cleaner structure.
edit2: I found out, that if I replace the value of the p:inputText
#{user.value}
to something static like e.g. #{bean.value123}
it works! So the problem seems to be with the var
attribute?
My xhtml:
<h:form id="myForm">
<ui:repeat var="user" value="#{bean.userForInputs.entrySet().toArray()}">
<p:inputText value="#{user.value}">
<p:ajax event="blur" listener="#{bean.updateMethod}" process="@this"/>
</p:inputText>
</ui:repeat>
</h:form>
My backing bean:
public void updateMethod(final AjaxBehaviorEvent event) {
System.out.println();
}
public void updateMethod() {
System.out.println();
}