JSF wrong display of elements when iterating a Map -
i have simplify problem as possible. basically, map
not been printed correctly after make modifications on it.
i have following xhtml code:
<c:foreach items="#{personcontroller.groupedpersons}" var="persong"> <p> <h:commandbutton action="#{personcontroller.removepersongroup(persong.key)}" type="submit" value="remove"> <f:ajax render="@form" /> </h:commandbutton> </p> <p>#{persong.key}</p> <p>#{persong.value.size()}</p> </c:foreach>
this iterates on map
, prints information. each key, there button allows removing map.
with code in personcontroller
bean (which @viewscoped
, implements serializable
):
private hashmap<integer, list<person>> groupedpersons; public void removepersongroup(integer age) { groupedpersons.remove(age); }
my testing data has key=20 , 3 values (person) , key=30 , 1 value (person). first time load page , print map works fine.
- 1st test: press button 2nd group (key 30). removes group , prints map fine, remaining group. press button 1st group (key 20). removes group , prints map fine, empty.
- 2nd test: reload page. press button 1st group (key 20). traces shows
removepersongroup()
works fine ,groupedpersons
has single element of key=30. however, when ajax refreshes form, xhtml shows#{persong.key} = 20
(which has been removed) ,#{persong.value.size()} = null
(nothing shown,value
empty). doing wrong? cannot find problem
update
after doing 2nd test , having wrong deta displayed in xhtml, when refresh form button , refresh whole page, xhtml shows actual data correctly! there must (concurrency related?) making xhtml show wrong data.
Comments
Post a Comment