2

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();
}
Christian
  • 113
  • 1
  • 3
  • 8
  • The code you've shown seems to be ok, what about the backing bean java code? – VeenarM Mar 19 '14 at 20:41
  • I added the backing bean. The method is overloaded, as I dont know if I have to pass the AjaxBehaviorEvent (read it in some post from BalusC). – Christian Mar 19 '14 at 20:56
  • Can you try removing the first backing bean method. (the one with the ajax behavior event) - then debug to see if it's called, it does look fine. What version of pf/jsf are u using – VeenarM Mar 19 '14 at 22:28
  • I am using javax.faces 2.2.0 and primefaces 4.0. I removed the first method, but it made no different. Another thing I tried was replacing the ui:repeat with a p:datatable, but the same thing happend: The ajax blur event on the dynamically created p:inputField was never thrown/catched. – Christian Mar 20 '14 at 19:52
  • Try giving your inputText and id value and adding a varStatus="loop" to your ui:repeat - could be losing it's place in the repeating. I'll have a try at work later. – VeenarM Mar 20 '14 at 21:16

0 Answers0