[jboss-user] [JBoss Seam] - How to update @DataModel and its ListDataModel?

bfo81 do-not-reply at jboss.com
Tue Aug 1 07:17:09 EDT 2006


I have an Entity Person (my favorite example *g*) and a page that lists all instances.

Here are some code snippets, believe me, it's simple ;).

The class delivering the list:

  | @Stateful @Scope(ScopeType.SESSION) @Name("personList")
  | public class ....
  | ...
  |     @DataModel
  |     private List<Person> persons;
  | 
  |     @Factory("persons")
  |     @Observer("personChanged")
  |     public void loadList() {
  |         person = em.createQuery("from Person");
  |         log.info("Persons are: " + persons);
  |     }
  | ...
  | 

The JSF:

  | ...
  | <h:dataTable var="person" value="#{persons}">
  |   ....
  | </h:dataTable>
  | 


Well, whenever a person is changed, added or deleted, the "personChanged" event is fired. This works perfectly, since the log always shows that really the newest state of all persons has been fetched from the database. If I just changed "John Doe" to "John Sixpack" then the change is shown in the persons variable immediately.

BUT: The underlying ListDataModel (@DataModel wraps the java.util.List into a org.jboss.seam.jsf.ListDataModel) is only up to date after deleting or adding a Person, namely changing the number of all entries. If I change an existing Person then the ListDataModel doesn't change and the overview page shows the old status.

So the List is up to date, the ListDataModel isn't (I found this out by adding a toString() method to ListDataModel that shows the wrapped data und outputting it via <h:outputText value="#{persons}" />).

QUESTION:
* How can I tell the ListDataModel that it should update its wrapped data?
* Why does this only work automatically when changing the length of a list? (I'm curious ;))
    

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962112#3962112

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3962112



More information about the jboss-user mailing list