-
1. Re: FacesMessage after exception
ssamayoagt Mar 10, 2010 9:21 PM (in response to mvlach)May be this?
@End
public String save() {
...try {
em.persist(instance);
// Persisted message
facesMessages.addFromResourceBundle(...);
} catch(Excpetion ex) {
//Something is wrong
facesMessages.addFromResourceBundle(...);
...
}
}Regards.
-
2. Re: FacesMessage after exception
cash1981 Mar 10, 2010 10:21 PM (in response to mvlach)Probably because when exception occurs your facesMessage isnt executed. What Sergio suggest would be the correct way. (Or you can add error message from pages.xml handling the exception)
-
3. Re: FacesMessage after exception
mvlach Mar 10, 2010 10:31 PM (in response to mvlach)I think you both are not right, because:
not thrown an exception. The exception can occurs in seam code, not in this function. The problem is that the facesMessages is added to the Seam. In persist is not called database queries and the possible error cannot be visible:
Then occurs error for example with unique keys, the hibernate will throw an exception very later, but the message
All is successfully updated
appears in second page invocation.Doesn't make sense.
Thanks Mila
-
4. Re: FacesMessage after exception
cash1981 Mar 10, 2010 10:50 PM (in response to mvlach)No we are not wrong. Its only you who have not enough knowledge of how Seam works.
If you look in your logs you will probably see
A message has been queued but not shown
. (Or something similar).This means you should do a proper redirect. That way it will show the message. Put a <redirect/> in pages.xml for that method, and the error message should appear in the same page the error occurs. (If you do not have error handling in pages.xml).
Also, if exception is thrown in your line em.persist, then facesMessage will in your exception will get invoked. Easy as that. That is how try catch works in programming languages.
-
5. Re: FacesMessage after exception
chits98 Mar 21, 2010 8:16 PM (in response to mvlach)What if there is no exception when calling persist, but an exception occurs during commit?
-
6. Re: FacesMessage after exception
cash1981 Mar 22, 2010 8:51 PM (in response to mvlach)
Pauline Daniel wrote on Mar 21, 2010 20:16:
What if there is no exception when calling persist, but an exception occurs during commit?The persist call will do a commit, thus it is that call that will catch the exception. So its the same.