0

I have again :-( a weird problem with a p:calendar inside a p:dataTable:

<h:form id="fId">
  <p:dataTable var="cum" value="#{myBean.list}">
    <p:column>
      <p:calendar value="#{cum.validFrom}">  
        <p:ajax update=":fId" event="dateSelect" listener="#{myBean.upDateCum}"/>  
      </p:calendar>  
    </p:column>
    <p:column>
      <h:outputText value="#{cum.validFrom}"/>
    </p:column>
  </p:dataTable>
</h:form>

The method in the bean is getting the correct element where the update occurs ( JSF p:calendar in p:dataTable: How to get the row of p:ajax dateSelect event ) then the date in the element is updated and list gets reordered. The correct ordering and updating can be verified in the bean at the end of the upDateCum method:

public void upDateCum(DateSelectEvent event)
{
    // Logging Before (iteration over list, debugging id and date)
    // set date with provided date from event
    // Logging After (iteration over list, debugging id and date)
}

20:53:10,455 INFO  [myBean]  Before id:148 -- 2012-04-15
20:53:10,456 INFO  [myBean]  Before id:141 -- 2012-04-10
20:53:10,456 INFO  [myBean]  Before id:147 -- 2012-04-05

20:53:10,823 INFO  [myBean]  After id:147 -- Fri Apr 20 00:00:00 CEST 2012
20:53:10,823 INFO  [myBean]  After id:148 -- 2012-04-15
20:53:10,823 INFO  [myBean]  After id:141 -- 2012-04-10

But the row of the table in which the change occurs contains always the value which actually was changed there (see image), but now should belong to another row (because of reordering).

The date in the third row (object.id=147) was changed from 05.04.12 to 20.04.12. After the update the changed date is in the first position (which is ok). But the third row does not contain the unchanged date of id=141, it holds the new data (20.04.12):

enter image description here

Interestingly: The h:outputText also contains the wrong date. I only can assume that the p:calendar is overriding the value after the beans method is executed.

Community
  • 1
  • 1
Thor
  • 6,545
  • 13
  • 61
  • 94
  • you better use update="@form" instead update=":id_of_form" , also the : is not needed here... can you confirm that upDateCum changed the right elements in the list ? – Daniel Apr 26 '12 at 17:14
  • Ok, tried `@form`, but without success. Only one element is updated and the debug output (see above) confirms that it's the correct element, also the list is ordered correctly. – Thor Apr 26 '12 at 18:33
  • did you iterated over the list in the java code before and after and it "reflects" the value that are displayed on page? – Daniel Apr 26 '12 at 18:36
  • yes, I've done this with iterations. See updated question. – Thor Apr 26 '12 at 18:55
  • any chance its cause of the way you getting the row id... (have you tried the ui.getParent().getId() way... ? by ref stuff and etc... ?) – Daniel Apr 26 '12 at 19:06
  • Yes, I also tried it the way you proposed (a `ui.getParent().getParent().getClientId()` gives the row id), but no luck. – Thor Apr 26 '12 at 19:30

0 Answers0