-
1. Re: Problems with AJAX and update model
tom_goring Mar 10, 2008 11:33 PM (in response to luisfelipe)1) Use richface attribute
bypassUpdates="false"
to not update your domain model2) Make sure you have
FlushModeType.MANUAL
EG@Begin(flushMode=FlushModeType.MANUAL)
Read Seam doco about that
-
2. Re: Problems with AJAX and update model
tom_goring Mar 10, 2008 11:58 PM (in response to luisfelipe)that should have read
bypassUpdates="true"
I guess it's the flush mode that is your main problem as you are dealing with an attached entity.
-
3. Re: Problems with AJAX and update model
alessandro Mar 11, 2008 2:23 PM (in response to luisfelipe)
Tom Goring wrote on Mar 10, 2008 11:58 PM:
that should have readbypassUpdates="true"
I guess it's the flush mode that is your main problem as you are dealing with an attached entity.I have the same problem and I do not know the answer.
Using:
bypassUpdates = "true"
...isn't appropriate, because the fields that are in the reRender don't show updated (And this is important when using AJAX).Using:
flushMode = "manual"
...also does not solve the problem.
The model is not persisted in dataBase, but if you click a button likeCancel
(with immediatetrue
), the object is still to the state in memory modified by Ajax. If another page to display the object, it will be with wrong values.Somebody has some tips?
-
4. Re: Problems with AJAX and update model
pmuir Mar 11, 2008 2:30 PM (in response to luisfelipe)I don't understand. You want to update the values on the page without updating the entity values? You can't do this with JSF/Ajax4jsf.
-
5. Re: Problems with AJAX and update model
damianharvey.damianharvey.gmail.com Mar 11, 2008 2:31 PM (in response to luisfelipe)So the problem you have now (using flush=manual) isn't that the Entity is updated in the database, it's that the Entity has the new (wrong) values when it is displayed on a subsequent page?
If so why not call a refresh() from your cancel? Or end the conversation & start a fresh one on the next page.
Cheers,
Damian.
-
6. Re: Problems with AJAX and update model
alessandro Mar 11, 2008 2:39 PM (in response to luisfelipe)
Pete Muir wrote on Mar 11, 2008 02:30 PM:
I don't understand. You want to update the values on the page without updating the entity values? You can't do this with JSF/Ajax4jsf.I need update the values on the page, but if user click on the button
Cancel
,Back
or others that notSave
button, the model must discard the new values. -
7. Re: Problems with AJAX and update model
damianharvey.damianharvey.gmail.com Mar 11, 2008 2:44 PM (in response to luisfelipe)If you use manual flush the model won't be updated to the Database until you call entityManager.flush().
If you call a refesh() on your Cancel() or Back() then the model will be reloaded from the database.
Cheers,
Damian.
-
8. Re: Problems with AJAX and update model
alessandro Mar 11, 2008 3:45 PM (in response to luisfelipe)Hi Damian ...
I have done some tests with flushMode manual, but without success.
The data are not recorded in the database, but I believe that the modified objects are cached, as on other pages it appears modified.Even if I click the button refresh
on browser
on other pages, the values appear incorrect (but in the database are correct).The situation is:
-- An objectA
have the one attribute with List of objectsB
.
This attribute is the value of datatable onpage1.xhtml.
The row of datatable is link for edit object
B
inpage2.xhtml.
-- If I change the object B, with an event AJAX but not save, and click the h: commandButton
Back
, thepage1.xhtml
show the dataTable with a row modified.-- In the database, the value is the old (fine!), but in
page1.xhtml
is the new (wrong) value of AJAX modified on page2. Even if I click the refresh browser, the value continues changed.Do you have some idea of why this happens?
Thanks -
9. Re: Problems with AJAX and update model
damianharvey.damianharvey.gmail.com Mar 11, 2008 3:51 PM (in response to luisfelipe)Hibernate has cached it. That's why you need to call an entityManager.refresh() (not a browser refresh) to reload the cached entity.
Cheers,
Damian.
-
10. Re: Problems with AJAX and update model
alessandro Mar 11, 2008 4:22 PM (in response to luisfelipe):-)
This working!I had confused with refresh, sorry.
This use like:
DataTable filter / Edit the object / Save-Cancel the object and use Ajax on the pages is very common. Does Seam along with the Hibernate could not have a new feature a bit morenatural
for these cases?The s: button with implicit
refresh
orPartial Flush
(with auto flush only in CRUD operations) would be very cool.Well, thank you very much!
-
11. Re: Problems with AJAX and update model
luisfelipe Mar 11, 2008 4:25 PM (in response to luisfelipe)Thanks Alessandro, Damian and Pete!
My problem has been resolved and my application is running, thank collaboration to clarify my doubts!
Thank very much!
-
12. Re: Problems with AJAX and update model
alessandro Mar 31, 2008 10:30 PM (in response to luisfelipe)How to disable this cache of Hibernate?
This very difficult to control the refresh button, because the user may not click on the button (with refresh action in entityManager) and click another button to any page (or links).
-
13. Re: Problems with AJAX and update model
pmuir Apr 2, 2008 2:59 PM (in response to luisfelipe)Damian is describing the first level cache provided by the persistence context. Read a good book (like Christian's) on JPA.