SFSB are evil? (The eternal Update problem)
dahm Jun 21, 2006 4:30 AMHi,
I seem to have a general problem with refreshing views from the database
when using SFSB like in the examples.
Remember the messages list example, I've got except pretty much the
same code, except there is a link on the page where you can edit the specified row entry.
@Stateful @Scope(ScopeType.SESSION) @Name("listVertraege") @Interceptors(SeamInterceptor.class) public class ListVertragActionBean implements Serializable, ListVertragAction { private static final Category _logger = Logger.getInstance(ListVertragActionBean.class); private static final long serialVersionUID = 1L; @DataModel(value = "vertraege") private List<Vertrag> _vertraege; @Out(required = false, value = "vertrag") @DataModelSelection private Vertrag _vertrag; @SuppressWarnings("unused") @Out(value = "vertragReadOnly", required = false) private Boolean _vertragReadOnly; @PersistenceContext(type = EXTENDED) private EntityManager _em; @SuppressWarnings("unchecked") @Factory("vertraege") public void findVertraege() { _vertraege = _em.createQuery("from Vertrag v order by v.vertragsBeginn").getResultList(); } public String select() { return "selected"; } public String delete() { _vertrag.removeAllVertragspartner(); _vertrag.removeAllPatient(); _vertraege.remove(_vertrag); // Auch aus dem Datenmodell entfernen _em.remove(_vertrag); _vertrag = null; return "deleted"; } public String edit() { return rereadAndEdit(false); } public String end() { return rereadAndEdit(true); } private String rereadAndEdit(boolean readonly) { _vertragReadOnly = readonly; // May be modified meanwhile _em.refresh(_vertrag); return "editVertrag"; } @Remove @Destroy public void destroy() { } }
Now the problem is that the data model isn't updated when I've modified
the data somewhere else (The changes are in the database).
I checked it, and the find() method is not called when I revisit the page.
How can I enforce that the list is reread?
This is a general problem I have with SFSB, the caching ignores
database changes or worse overrides them. I had the suspect that
this could be someting with the way I implemented the equals()
method for the Vertrag class, but after modification it still didn't work
By the way setting scope=PAGE in the @DataModel didn't work. The data
may be reloaded every time, but the @DataSelection _vertrag field isn't
set anymore (always null) and the select(), end() and edit() methods are not called.
Any help will be appreciated...
Cheers
Markus